Fire event when clicking on the specific cell

G

Guest

i wants that the Event would fie when we click on DataGrid using Asp.net without using any select command or hyperlink. i just want that user click on the specific cell of datagrid then the even occurs for cell and tell us which cell have, we click
thanx
tenzeel.
 
J

John Saunders

Please don't ask the same question 10 times! You have received many answers.

--
John Saunders
johnwsaundersiii at hotmail


tenzeel. said:
i wants that the Event would fie when we click on DataGrid using Asp.net
without using any select command or hyperlink. i just want that user click
on the specific cell of datagrid then the even occurs for cell and tell us
which cell have, we click
 
G

Guest

In order to add click event to the entire row of datagrid, add a link button as a hidden column to the datagrid and then in ItemDataBound event of datagrid, we can attribute the link click event to the entire row in the following way :
//Get the link button
LinkButton lnkButton = (LinkButton)grdEventArgs.Item.Cells[0].Controls[0];

// add the click event to the entire list item
grdEventArgs.Item.Attributes["onclick"] = Page.GetPostBackClientHyperlink(lnkButton, "");

thats it..when the user clicks on the row, the row is selected and SelectedIndex event is fired which we can catch in the code behind and get the SelectedIndex value.
hope this answers you.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top