Handling events triggered by dynamically created controls

Discussion in 'ASP .Net' started by Nathan Sokalski, Feb 27, 2008.

  1. I have a series of LinkButtons that I need to be able to handle the postback
    events for. The controls are created dynamically, and how many there will be
    will vary. I was previously told to create them in the Page's Init event and
    to make sure the same ID is used. Here are the problems I am having with
    that:

    1. In the Init event I do not know how many I need to create.

    2. How do I know what the ID's were?

    Any help would be appreciated (and if you know of any sites with good
    examples that would definitely be nice). Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Feb 27, 2008
    #1
    1. Advertising

  2. Nathan Sokalski

    bruce barker Guest

    use a hidden field or viewstate to store the number of controls, and any
    other info you need.

    -- bruce (sqlwork.com)


    "Nathan Sokalski" wrote:

    > I have a series of LinkButtons that I need to be able to handle the postback
    > events for. The controls are created dynamically, and how many there will be
    > will vary. I was previously told to create them in the Page's Init event and
    > to make sure the same ID is used. Here are the problems I am having with
    > that:
    >
    > 1. In the Init event I do not know how many I need to create.
    >
    > 2. How do I know what the ID's were?
    >
    > Any help would be appreciated (and if you know of any sites with good
    > examples that would definitely be nice). Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    >
    >
    bruce barker, Feb 27, 2008
    #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. Nathan Sokalski

    Handling Events for Dynamically Created Controls

    Nathan Sokalski, May 23, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    971
    Herfried K. Wagner [MVP]
    May 23, 2005
  2. Mark
    Replies:
    3
    Views:
    486
    Mark Rae
    Jan 8, 2007
  3. msimmons
    Replies:
    0
    Views:
    444
    msimmons
    Jul 16, 2009
  4. Nathan Sokalski

    Handling Events for Dynamically Created Controls

    Nathan Sokalski, May 23, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    116
    Herfried K. Wagner [MVP]
    May 23, 2005
  5. Nathan Sokalski

    Handling events triggered by dynamically created controls

    Nathan Sokalski, Feb 27, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    114
    bruce barker
    Feb 27, 2008
Loading...

Share This Page