checkboxlist help

Discussion in 'ASP .Net Web Controls' started by Jasmine, May 7, 2005.

  1. Jasmine

    Jasmine Guest

    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.
    Jasmine, May 7, 2005
    #1
    1. Advertising

  2. 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:
    > 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.
    >
    >
    >
    >
    >
    >
    Scott Mitchell [MVP], May 8, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JD
    Replies:
    5
    Views:
    11,623
    NetArchitect
    Aug 8, 2007
  2. =?Utf-8?B?QnVsaXd5Zg==?=

    CheckBoxList HELP URGENT!!!

    =?Utf-8?B?QnVsaXd5Zg==?=, Jun 10, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    347
    =?Utf-8?B?QnVsaXd5Zg==?=
    Jun 10, 2005
  3. Patrick.O.Ige
    Replies:
    5
    Views:
    19,078
    Patrick.O.Ige
    Jun 19, 2005
  4. Patrick.O.Ige

    Help with CheckBoxlist!

    Patrick.O.Ige, Jul 29, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    499
    Patrick.O.Ige
    Jul 30, 2005
  5. Replies:
    0
    Views:
    5,550
Loading...

Share This Page