Dynamic Control capture button click.

Discussion in 'ASP .Net Web Controls' started by sakieboy, Feb 28, 2005.

  1. sakieboy

    sakieboy Guest

    I have dynamically added controls using a Placeholder to a form. This form
    is data driven thus I never know how many records will be retrieve. My form
    looks like this
    txtKey0=1111, txtBox0, txtDate0, btnEdit0
    txtKey1=2323, txtBox1, txtDate1, btnEdit1
    txtKey2=4343, txtBox2, txtDate2, btnEdit2
    etc.

    When I select a button I need to find out what my txtkey value is so that I
    can pass it to a Querystring and display another page. Of course, currently
    I only have one btnEdit_Click event which seems pretty lost. How do I get my
    key values depending upon the button that I select. Or would I be better off
    putting this in a datagrid control?
    sakieboy, Feb 28, 2005
    #1
    1. Advertising

  2. sakieboy

    Wilco Bauwer Guest

    A datagrid, repeater or datalist may be a good choice. If you do not
    use that, then you can set the button's CommandName and CommandArgument
    properties. Instead of handling their click event, you should then
    handle the Command event. All controls' Command event can have the same
    event handler. Inside that event handler you can then extract the
    information from the CommandName/CommandArgument properties to do your
    thing.

    In case you have problems related to dynamically loaded controls, you
    may also want to take a look at
    http://wilcoding.xs4all.nl/Wilco/View.aspx?NewsID=147.

    ----
    - Wilco Bauwer
    Blog & Custom Controls @ http://wilcoding.xs4all.nl
    Wilco Bauwer, Feb 28, 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. Purvi T
    Replies:
    0
    Views:
    820
    Purvi T
    Oct 19, 2004
  2. Lloyd Sheen

    Capture button click in datagrid

    Lloyd Sheen, Sep 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,798
    Ben Lucas
    Sep 29, 2004
  3. =?Utf-8?B?RmVuZw==?=
    Replies:
    1
    Views:
    9,881
    Scott M.
    Nov 1, 2005
  4. Amy
    Replies:
    0
    Views:
    958
  5. Replies:
    0
    Views:
    421
Loading...

Share This Page