|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Don't understand state in WebControls classcheckboxes 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! They should be added to Controls collection in PreRender stage
(Page_PreRender method or overridden OnPreRender method), so that state gets saved. Plus that they are dynamical controls, they would need to be recreated on postback. http://aspadvice.com/blogs/joteke/archive/2006/01/06/14568.aspx -- Show quoteHide quoteTeemu Keiski ASP.NET MVP, AspInsider Finland, EU http://blogs.aspadvice.com/joteke <kasterbo***@yahoo.com> wrote in message news:1156444432.679943.315250@b28g2000cwb.googlegroups.com... > 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! >
objectdataSource case sensitive with parameters??
label overlap during design Dynamic gridview values lost on postback button problem Menu Wrap Problem FormView and HTMLEncode asp:hyperlinkfield format dinamically-created checkbox doesn't load it's state GridView edit mode problem dynamically set property on a control |
|||||||||||||||||||||||