Don't understand state in WebControls class

K

kasterborus

I've been working on a web control class that generates a grid of
checkboxes dynamically, based upon a DB query. I've been creating them
in the Render method as needed.


CheckBox _cb = new CheckBox();
_cb.Text = "Assigned";
_cb.RenderControl(tw);

The only problem is of course any user interaction with the checkboxes
is lost when posting back.

I've tried adding them to the .Controls collection, setting
EnableViewState to true, but nothing seems to work. The closest I've
come to success is when I store the Checkboxes in the Viewstate
explictly, but they are the "previous" checkboxes - no user interaction
is recorded in them after postback.

I know this has something to do with EnsureChildControls() and
CreateChildControls() but all my attempts so far have failed.

How do I tie a checkbox control (newly created or otherwise) to the
state of the checkbox in the HTML, so that it contains any new user
interaction?

Thanks in advance!
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top