Method to get DataKey from a GridView RowCommand Event
protected void grdEmployees_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
int index = row.RowIndex;
int employeeID = Convert.ToInt32(grdEmployees.DataKeys[index].Value);
}
}
For this eg: There should be GridView Control with a TemplateField and that should contain a Linkbutton with CommandName="Select"
usefull...Worked for me in rowcommand event
ReplyDeleteThank u...very Much...
ReplyDeleteIt's Really good....
ReplyDeletevery simply expalained...thnx alot
ReplyDelete