Question

I have an ASP.NET web form. In it is a short list of checkboxes. What I expect to have happen is I check a couple checkboxes, do a postback, and the checkboxes should remain checked after the postback.

For some reason, the checkboxes are unchecked on postback. I've got nothing in the page_init or page_load events that do anything with the checkboxes. And when I step through the code while debugging, the checkboxes are flagged as checked.

I tried setting the value of the checked property on postback to true, but the checkboxes still don't wind up checked.

Anyone seen this before and have any suggestions on how to fix it?

EDIT

I didn't realize at first - the checkboxes are html server controls (input type=checkbox runat=server...).

Was it helpful?

Solution

You need to override the SaveViewState and LoadViewState methods - and place the checkbox values into ViewState.

http://www.4guysfromrolla.com/articles/110205-1.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top