I have checked to make sure Enable ViewState is true. The CheckBoxList is
created in the design view, with all the ListItems being created at that
time. In my "Page_Load" section (and within the if(!IsPostBack) loop, is
where I set the Selected items. So they are not being set anywhere else.
The only thing different that I'm doing is, initially, all the controls on
the page are disabled. There is an edit button that, when the user clicks,
causes a postback and the event handler for that button calls a void that
enables the controls. It's during this postback that the view state for the
CheckBoxList appears to be lost.
I've since gone back and replaced this control with three seperate CheckBox
controls and the viewstate is working fine.
On a side note, I did read a reference to the CheckBoxList yesterday (can't
remember where just now), that indicated that the CheckBoxList control does
not implement ISerializable, so the the viewstate of the embedded ListItems
cannot be serialized and saved during postback situations, the suggested
alternative was to create an ArrayList to hold the state of the individual
ListItems during postback.
But, if you can get it to work for you, then I guess that article was bunk.
David
"Marshal Antony" <do***********@yahoo.com> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
typing mistake if(!Page.IsPostBack){}
"Marshal Antony" <do***********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Hi david,
I use CheckBoxList control a lot and I don't have any problems so far. Make sure your EnableViewState = true for the control.
Also if you load the items to the control in the
Page_Load event,make sure to put it in if(!Page.Postback){},
otherwise when you post back if you have some other code to populate
the checkboxlist can make loose the selected status .
I don't know your actual problem unless I see some code.Please provide
the sample code you are using with Checkboxlist
and on which events so that I may be able to help you.
Hope this helps.
Regards,
Marshal Antony
.NET Developer
http://www.dotnetmarshal.com
"dm_dal" <RE******************@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Is there a know issue surrounding the CheckBoxList control and it's
viewstate?
When my control is created, it's ListItems are checked as needed, but
on a postback, they loose their Selected status.
David