Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > checkboxlist help

Reply
Thread Tools

checkboxlist help

 
 
Jasmine
Guest
Posts: n/a
 
      05-07-2005
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.






 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      05-08-2005
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/de.../DynamicUI.asp

hth


Jasmine wrote:
> 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.
>
>
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxlist inside Repeater - doesn't fire click event for Checkboxlist JD ASP .Net 5 08-08-2007 11:28 AM
Help: Using Multiple Checkboxes or Checkboxlist to filter results in a gridview in ASP.NET 2.0 / VS2005 Faybert@gmail.com ASP .Net 0 12-29-2005 11:43 PM
Help with CheckBoxlist! Patrick.O.Ige ASP .Net 2 07-29-2005 11:46 PM
How to get Selected item in a Databinded CheckBoxList when CheckBoxlist is in a DataList? Patrick.O.Ige ASP .Net 5 06-19-2005 06:11 AM
CheckBoxList HELP URGENT!!! =?Utf-8?B?QnVsaXd5Zg==?= ASP .Net 0 06-10-2005 11:46 AM



Advertisments