How to make gridview rows clickable??
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
sameer gadade60 reputationPosted Jun 18, 2012, 9:09 PM EDT
use following line of code
use command field in grid view columns
hope this code will work for you
EX:
CssClass="grid_style" Width="750px"
onpageindexchanging="GridViewteacherdetails_PageIndexChanging"
onrowcreated="GridViewteacherdetails_RowCreated"
onsorting="GridViewteacherdetails_Sorting" AllowSorting="True"
BackColor="White" onselectedindexchanging="GridViewteacherdetails_SelectedIndexChanging"
>
Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 18, 2012, 10:02 PM EDT
Sameer Approch is good.Insted of you can also use RowDataBound events and in RowDataBound events bind javascript onclick event.
....
....
....
protected void gvSearch_RowDataBound(object sender, GridViewRowEventArgs e)
Also refer{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("style", "cursor:pointer;");
e.Row.Attributes.Add("onclick", "location='patron_detail.aspx?id=" + e.Row.Cells[0].Text + "'");
}
}
http://www.codeproject.com/Articles/15898/Select-a-row-in-a-grid-view-with-a-click-on-row
hope this will help you.