|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
checkboxlist helpIn my code I dynamically create web controls. My problem is newCheckBoxList = new CheckBoxList(); newCheckBoxList.EnableViewState = true; newCheckBoxList.AutoPostBack = true; newCheckBoxList.SelectedIndexChanged += new System.EventHandler(Checked_Changed); When I create a dynamic checkboxlist like that, I handle the selected index changed event but my page refreshes and all controls I have drawn disappears. Instead of that when I only create the checkboxlist and dont use the last 3 commands, I have selected index -1 when I control the checkbox list. Is there any way to store selected indexes without enabling autopostback? Thanks. Jasmine, when working with dynamically-created controls it is essential
that you add these controls and their event handlers ON EACH AND EVERY POSTBACK. Check out these articles for more on working with dynamic controls in ASP.NET: http://aspnet.4guysfromrolla.com/articles/081402-1.aspx http://aspnet.4guysfromrolla.com/articles/082102-1.aspx http://aspnet.4guysfromrolla.com/articles/092904-1.aspx http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/DynamicUI.asp hth Jasmine wrote: Show quoteHide quote > hi all, > > In my code I dynamically create web controls. My problem is > newCheckBoxList = new CheckBoxList(); > > newCheckBoxList.EnableViewState = true; > > newCheckBoxList.AutoPostBack = true; > > newCheckBoxList.SelectedIndexChanged += new > System.EventHandler(Checked_Changed); > > When I create a dynamic checkboxlist like that, I handle the selected index > changed event but my page refreshes and all controls I have drawn > disappears. Instead of that when I only create the checkboxlist and dont > use the last 3 commands, I have selected index -1 when I control the > checkbox list. > > Is there any way to store selected indexes without enabling autopostback? > > Thanks. > > > > > >
DropDownList selectedIndexChanged event not firing
LinkButton Control Validator Control Change print orientation by website Image auto sizing in asp.net VS.NET 2003 using ASP.NET & VB.NET -- IDE design time problems? DataGrid SortCommand Event not fired on dynamically generated datagrid Syntax for "NULL" in asp.net DropDownList postback Format textbox to time format |
|||||||||||||||||||||||