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

[Solved] Do you need a GridBoundColumn column in order to have the value on the DataKeyNames?

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alejandro
Top achievements
Rank 1
Alejandro asked on 21 Aug 2013, 04:11 PM
imagine i have

DataKeyNames="CollectionId, ClaimTypeId"

Do i need a

 <telerik:GridBoundColumn DataField="claimtypeid" UniqueName="claimtypeid" HeaderStyle-HorizontalAlign="Center"
                                        HeaderText="claimtypeid" Visible="false">
                                    </telerik:GridBoundColumn>

??
notice the visible = false

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Aug 2013, 04:08 AM
Hi Alejandro,

If you want to set a column as DataKeyValue,please set it as DataKeyNames="DataFieldNames".Its not necessary to set it as a bound column to access it.Please find the below code snippet.

ASPX:
<MasterTableView DataKeyNames="OrderID">

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem item = (GridDataItem)e.Item;
           var value = item.GetDataKeyValue("OrderID");//Access the datakeyname values  ,without setting in bound column       
       }
   }

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