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