c# gridview row click

后端 未结 9 1943
野的像风
野的像风 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条回答
  •  旧时难觅i
    2020-12-01 10:05

    I have the solution.

    This is what i have done:

    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        e.Row.Attributes["onClick"] = "location.href='view.aspx?id=" + DataBinder.Eval(e.Row.DataItem, "id") + "'";
    }
    

    I have putted the preceding code in the RowDataBound event.

提交回复
热议问题