This example uses composite primary key for showing more complicated usage.
gvUsersInRoles.DataSource=taUsersInRoles.GetData();
gvUsersInRoles.DataKeyNames = new string[] { "UserId", "RoleId" };
gvUsersInRoles.DataBind();
Getting primary key values during performing row command (command, insert, delete, update):
Guid uid = new Guid(gvUsersInRoles.DataKeys[e.RowIndex]["UserId"].ToString());
int pid = int.Parse(gvUsersInRoles.DataKeys[e.RowIndex]["RoleId"].ToString());
No comments:
Post a Comment