Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to find which cell is clicked in a gridview in asp.net ?
Posted

1 solution

By default, GridView does not support cell click event handling but you can add that feature.

Have a look at this article: Extended ASP.NET GridView with cell click events[^]

In case you just need to do some small things for the control click in a particular cell, try:
C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
 if ( e.Row.RowType == DataControlRowType.DataRow )
  // for example, you got linkbutton in that cell
  LinkButton linkButton = (LinkButton)e.Row.FindControl("LinkButton1");

  if (linkButton != null)
  {
    // do your stuff
    //linkButton.Attributes.Add("onclick", "window.open('someURL'); return false;");
  }
 }
 
Share this answer
 
Comments
Maciej Los 5-May-12 5:07am    
AS always, very good answer! My 5!
Sandeep Mewara 5-May-12 5:13am    
Thanks man. :)
Manoj Kumar Choubey 5-May-12 7:11am    
+5
Sandeep Mewara 5-May-12 8:23am    
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900