Get RadGrid Datakey item id from itemcommand
Posted on: Fri Aug 20 16:39:45 -0700 2010. Updated on: Fri Aug 20 16:40:30 -0700 2010.
Category: Telerik Controls and Sitefinity
Category: Telerik Controls and Sitefinity
This is useful when you have a RadGrid with a codebehind ItemCommand that gets executed when action is done on a particular row. This will get you the datakey id, ie the Primary Key of the row object
protected void RadGridNonAffiliateUsers_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == "makeAffiliate")
{
Guid userId = new Guid(RadGridNonAffiliateUsers.MasterTableView.DataKeyValues[e.Item.ItemIndex]["CategoryId"].ToString());
AffiliateDO.MakeUserAffiliate(userId);
RadGridNonAffiliateUsers.DataBind();
}
}