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

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();
			}
		}

Comments:

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.