c# gridview row click

后端 未结 9 1937
野的像风
野的像风 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:08

    row click in grid view redirect to other page

        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 + "'";
            }
        }
    

    works absolutely fine

提交回复
热议问题