如何给网格行一行命令

时间:2009-12-28 15:17:29

标签: c# .net asp.net visual-studio gridview

我想让gridview行可选。我不喜欢用户点击网格上的按钮或链接来选择行的想法。如何给行实际行命令?

1 个答案:

答案 0 :(得分:1)

您就是这样做的。

 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);

    }

}