CheckBoxList losing viewstate

D

dm_dal

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

DMY
 
T

Teemu Keiski

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


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

DMY
 
D

dm_dal

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.
 
T

Teemu Keiski

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

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.
 
T

Teemu Keiski

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




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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top