This is a migrated thread and some comments may be shown as answers.

[Solved] Getting Underlying Data IDs

1 Answer 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zach Alsgaard
Top achievements
Rank 1
Zach Alsgaard asked on 13 Jun 2008, 08:12 PM

I have some RadGrids bound to some data and I need to be able to get the IDs from the underlying data.  I checked your documentation and saw the following code for doing this:

I have also seen code like the following to do the same thing:

Are there any cleaner ways to get these IDs from our Rad Grids?

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Jun 2008, 06:23 AM
Hi,

Try accessing the DataKeyName in the code behind as shown below.

ASPX:
<MasterTableView    DataKeyNames="CustomerID"     > 

CS:
  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem)  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            string strKey = item.GetDataKeyValue("CustomerID").ToString();  
        }  
    } 

Thanks
Princy.
Tags
Grid
Asked by
Zach Alsgaard
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or