This below codes give me error below: How to generate this codes help me please!!!
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
protected void gvDepartman_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string selectedid = (gvDepartman).DataKeys[e.Row.RowIndex].Value.ToString();
e.Row.Attributes["onclick"] = "location.href='Test.aspx?id=" + selectedid + "'";
}
}