Capture the click event of a template link button

D

Darren Wooding

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
 
T

Teemu Keiski

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.
 
D

Darren Wooding

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top