468,766 Members | 1,297 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,766 developers. It's quick & easy.

? Known Issue: CheckBoxList & viewstate

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
Nov 18 '05 #1
4 7848
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

Nov 18 '05 #2
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


Nov 18 '05 #3
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



Nov 18 '05 #4
David,
After testing Checkboxlist with the Enabled property I found that
there is a bug with CheckBoxList control.
I didn't experience the problem in my applications because I was not
disabling and enabling the CheckboxList control.
The testing I have done:
Set the enabled property of the Checkboxlist control to
false.While Page_Load, in !Page.IsPostBack set the Selected property
of an item in the Checkbox.After loading the Webform,click on a button
where the enabled property of the Checkboxlist is set to true,the result is,
that item is unchecked!!. I did the same testing for a list box and it is
preserving the selected property.
May be somebody at Microsoft can help you with this bug.
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com


"dm_dal" <RE******************@yahoo.com> wrote in message
news:uG**************@TK2MSFTNGP09.phx.gbl...
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
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dave Bartlett | last post: by
1 post views Thread by Neven Klofutar | last post: by
reply views Thread by sdoerfli | last post: by
2 posts views Thread by jwnews1231 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.