c# gridview row click

后端 未结 9 1923
野的像风
野的像风 2020-12-01 09:34

When I click on a row in my GridView, I want to go to a other page with the ID I get from the database.

In my RowCreated event I have the following line:

         


        
9条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 10:01

    protected void gvSearch_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string abc = ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
            e.Row.Attributes["onClick"] = "location.href='Default.aspx?id=" + abc + "'";    
        }
    }
    

提交回复
热议问题