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

Rad Grid Edit the Row

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mani
Top achievements
Rank 1
mani asked on 24 Feb 2009, 06:32 PM
Hi
      I ask the questions to  u. u send it answer to me.. ok it is fine working multiple user control within gird. i but i cant take the primay key id.. bz i give the rad grid keynames is contact type id... now how can i take the vlaue for forign key values.....

Regards
G. Manikandang

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Feb 2009, 07:13 AM
Hi Mani,

You can set multiple DataKeyNames for the grid, no matter if it is a PrimaryKeyValue or a ForeignKeyValue and retrieve it in the code behind. Check out the example below:
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" OnItemDataBound="RadGrid1_ItemDataBound"
     <MasterTableView DataKeyNames="ProductID,CategoryID"
         ....  

cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string productId = item.GetDataKeyValue("ProductID").ToString(); 
            string categoryId = item.GetDataKeyValue("CategoryID").ToString(); 
        } 
    } 

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