Repeater User Control and Viewstate

862 Views Asked by At

I maintain an ASP.NET Web Forms application on framework 3.5. Essentially it is a list of items and a checkbox to signify the state of the item. The users can sort the items by any of a number of columns. New items are added and removed between postbacks. This list is hosted in a Repeater and the item template is a usercontrol. The page has no master page as it is an application that was upgraded from framework 1.0 to 1.1 to 2.0 to 3.5. The application does this if it is hosted by IIS6.1 and 7.5, 32 bit and 64 bit. It is in it's own application pool and the pool has 4 threads.

Now the problem: If a checkbox is checked in the thrid row and the item in position 1 is removed in the database, then it should move up to position 2. It does move up, but the checked check box stays in position 3. If the rows are sorted, then all the checked checkboxes stay in their position, but the rest of the information is sorted and displayed correctly, including the title on the parent tag.

Viewstate is disabled on the user control, and on the checkbox within the user control. Caching of the page is disabled in a page directive. The repeater is bound in page load. I've checked the state of the controls in the repeater that should be checked right after repeater.DataBind and the state of the check boxes is correct. This is the last line in the page load event. Using fiddler I have verified that the rendered HTML is not correct. So it seems that the problem is somewhere in the render.

This is as far as I've been able to take this. The application is mission critical, yet this bug has existed for a very long time. Obviously the state of this checkbox wasn't that important, but due to evolving business requirements it is becoming an issue.

No searches come up with any bugs. I can post the code, but it is extremely long since it is part of a large applicaon, so I have not.

It appears that viewstate is being loaded between Page_Load and LoadComplete. Checking the values after databinding and LoadComplete shows this. What would cause viewstate to load at the wrong time like this. Feels like a bug. It only affects one page in the applicaon. I know that viewstate is populated after init and that all controls should be loaded during OnInit, but I don't want viewstate so it is ok that this doesn't function.

It has nothing to do with the type of control. I just exchanged the asp:checkbox for a htmlinputcheckbox and the behavior persisted.

EDIT: Would control state have anything to do with this? It can't be disabled so far as I know.

1

There are 1 best solutions below

1
On

After removing the asp:checkbox for an HtmlInputCheckBox and suffering the same problem. I determined that the probelm is with the check box in particular and exchanged it for an asp:ImageButton with fake check box image.

I believe, though I do not know for sure, that the check box state is a part of conrol state and not view state. Seems like a Microsoft Bug to me, but perhaps that is the way this control was designed.