CheckBoxList losing viewstate

Discussion in 'ASP .Net Web Controls' started by dm_dal, Feb 17, 2004.

  1. dm_dal

    dm_dal Guest

    Is this a known issue or something? During a postback, my CheckBoxList
    controls forget which ListItems are Selected.

    DMY
    dm_dal, Feb 17, 2004
    #1
    1. Advertising

  2. dm_dal

    Teemu Keiski Guest

    Are you rebinding the list or adding items dynamically? Tell us more.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist


    "dm_dal" <> wrote in message
    news:...
    Is this a known issue or something? During a postback, my CheckBoxList
    controls forget which ListItems are Selected.

    DMY
    Teemu Keiski, Feb 17, 2004
    #2
    1. Advertising

  3. dm_dal

    dm_dal Guest

    The ListItems are added design time.

    In the Page_Load section, enclosed within the if(!IsPostBack) is where I'm
    setting the Selected property for each ListItem. Initially, the
    CheckBoxList's enabled property is set to false, and when the user clicks
    the edit button, this control et.al. are set to enabled. It's during this
    postback that the ListItems lose their Selected state.


    "Teemu Keiski" <> wrote in message
    news:...
    > Are you rebinding the list or adding items dynamically? Tell us more.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    >
    > "dm_dal" <> wrote in message
    > news:...
    > Is this a known issue or something? During a postback, my CheckBoxList
    > controls forget which ListItems are Selected.
    >
    > DMY
    >
    >
    >
    dm_dal, Feb 17, 2004
    #3
  4. dm_dal

    Teemu Keiski Guest

    Hi,

    that is due to the nature of <input type=checkbox> HTML elements that they
    don't post their value when HTML element is disabled, causing selection to
    be lost on postback (despite do you change the CheckBoxList to enabled or
    not). .

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist

    "dm_dal" <> wrote in message
    news:%23%...
    The ListItems are added design time.

    In the Page_Load section, enclosed within the if(!IsPostBack) is where I'm
    setting the Selected property for each ListItem. Initially, the
    CheckBoxList's enabled property is set to false, and when the user clicks
    the edit button, this control et.al. are set to enabled. It's during this
    postback that the ListItems lose their Selected state.


    "Teemu Keiski" <> wrote in message
    news:...
    > Are you rebinding the list or adding items dynamically? Tell us more.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    >
    > "dm_dal" <> wrote in message
    > news:...
    > Is this a known issue or something? During a postback, my CheckBoxList
    > controls forget which ListItems are Selected.
    >
    > DMY
    >
    >
    >
    Teemu Keiski, Feb 18, 2004
    #4
  5. dm_dal

    Teemu Keiski Guest

    And to add that the behavior not to post value when INPUT element is
    disabled is in the HTML standard. Basically setting the element to be
    readonly could work, but not sure if it can be straightforward set to
    singular items in CheckBoxlist (ListItem has Attributes property but it
    doesn't seem to reflect added attributes what is known bug:
    http://support.microsoft.com/default.aspx?scid=kb;en-us;309338).

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist




    "dm_dal" <> wrote in message
    news:%23%...
    The ListItems are added design time.

    In the Page_Load section, enclosed within the if(!IsPostBack) is where I'm
    setting the Selected property for each ListItem. Initially, the
    CheckBoxList's enabled property is set to false, and when the user clicks
    the edit button, this control et.al. are set to enabled. It's during this
    postback that the ListItems lose their Selected state.


    "Teemu Keiski" <> wrote in message
    news:...
    > Are you rebinding the list or adding items dynamically? Tell us more.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    >
    > "dm_dal" <> wrote in message
    > news:...
    > Is this a known issue or something? During a postback, my CheckBoxList
    > controls forget which ListItems are Selected.
    >
    > DMY
    >
    >
    >
    Teemu Keiski, Feb 18, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    4
    Views:
    5,019
    Curt_C [MVP]
    Jan 30, 2004
  2. JD
    Replies:
    5
    Views:
    11,637
    NetArchitect
    Aug 8, 2007
  3. Patrick.O.Ige
    Replies:
    5
    Views:
    19,100
    Patrick.O.Ige
    Jun 19, 2005
  4. Earl Teigrob

    Losing viewstate after inheriting CheckBoxList

    Earl Teigrob, Oct 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    140
    Earl Teigrob
    Oct 3, 2006
  5. Jason C
    Replies:
    4
    Views:
    678
    Morty Abzug
    Jun 26, 2012
Loading...

Share This Page