yeasir007

Monday, November 04, 2013

Implement full row selection in C# asp.net GridView without select button

Implement full row selection in C# asp.net GridView without select button


Implement full row selection in C# asp.net GridView without select button:


This feature will be used to Select Full row of grid view instead of select button when user press on any point of this row.

protected void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow) {
        e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
        e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
        e.Row.ToolTip = "Click to select row";
        e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
    }
}