开发者

how to give a grid row a row command

开发者 https://www.devze.com 2022-12-15 10:56 出处:网络
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

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

    }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消