Capture the click event of a template link button

Discussion in 'ASP .Net Web Controls' started by Darren Wooding, Dec 31, 2003.

  1. Hi all,

    in my webform datagrid I add all columns and controls
    dynamically. In this case I don't have a lnkButton_Click
    event as the control is created at runtime through a
    template (but of course I can set the ID). How can I
    capture the _click event?

    Many thanks

    Darren
     
    Darren Wooding, Dec 31, 2003
    #1
    1. Advertising

  2. Darren Wooding

    Teemu Keiski Guest

    Hi,

    you could set CommandName and CommandArgument properties of button controls
    (Button,LinkButton,ImageButton) and get their clicking by handling
    ItemCommand event of the DataGrid. That way you wouldn't need to wire event
    handlers to contained controls.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist


    "Darren Wooding" <> wrote in message
    news:09b101c3cfc0$c65c8b10$...
    > Hi all,
    >
    > in my webform datagrid I add all columns and controls
    > dynamically. In this case I don't have a lnkButton_Click
    > event as the control is created at runtime through a
    > template (but of course I can set the ID). How can I
    > capture the _click event?
    >
    > Many thanks
    >
    > Darren
    >
     
    Teemu Keiski, Jan 2, 2004
    #2
    1. Advertising

  3. Thanks for the reply Teemu. I have also found that I can
    capture the event in the template with an AddHandler
    routine on the click event but what you suggested is much
    more useful as it keeps the button code at form level.

    Thanks for taking the time to reply.

    Darren

    >-----Original Message-----
    >Hi,
    >
    >you could set CommandName and CommandArgument properties

    of button controls
    >(Button,LinkButton,ImageButton) and get their clicking by

    handling
    >ItemCommand event of the DataGrid. That way you wouldn't

    need to wire event
    >handlers to contained controls.
    >
    >--
    >Teemu Keiski
    >MCP, Microsoft MVP (ASP.NET), AspInsiders member
    >ASP.NET Forum Moderator, AspAlliance Columnist
    >
    >
    >"Darren Wooding" <>

    wrote in message
    >news:09b101c3cfc0$c65c8b10$...
    >> Hi all,
    >>
    >> in my webform datagrid I add all columns and controls
    >> dynamically. In this case I don't have a

    lnkButton_Click
    >> event as the control is created at runtime through a
    >> template (but of course I can set the ID). How can I
    >> capture the _click event?
    >>
    >> Many thanks
    >>
    >> Darren
    >>

    >
    >
    >.
    >
     
    Darren Wooding, Jan 3, 2004
    #3
    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:
    896
    Purvi T
    Oct 19, 2004
  2. jorge
    Replies:
    2
    Views:
    1,315
    jorge
    May 26, 2004
  3. Amy
    Replies:
    0
    Views:
    1,015
  4. Max2006
    Replies:
    2
    Views:
    1,615
    Walter Wang [MSFT]
    Sep 19, 2007
  5. jorge
    Replies:
    1
    Views:
    434
    Teemu Keiski
    May 28, 2004
Loading...

Share This Page