I want to make my gridview rows selectable. I don't like the idea of a user clicking a button or link on the grid to select the row. H开发者_运维百科ow can I give the actual row a row command?
This is how you do it.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridView GridView1 = (GridView)frmViewClaimantPE.FindControl("GridView1");
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(GridView1, "Select$" + e.Row.RowIndex);
}
}
精彩评论