Generally we set the primary key values to the datakeyName property in gridview control and below code will help to get that date key values associated with a row in rowdatabound event.
protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string userID = gv1.DataKeys[e.Row.RowIndex].Values[0].ToString();
}
}
protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string userID = gv1.DataKeys[e.Row.RowIndex].Values[0].ToString();
}
}
No comments:
Post a Comment