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

DataKeyValues not populated

5 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 30 Jun 2010, 02:43 PM
I have downloaded the trial version of the Telerik controls to play around before purchasing.

I found a video on Telerik TV demostrating how to retreive primary keys from the RadGrid control.

I've followed the code in the video exactly but never is the DataKeyValues property populated.

Does anyone have any suggestions?

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2010, 07:20 AM
Hello Sean,

Have you added primary key field to the DataKeyNames array (if you are accessing from code behind)?
Retrieving primary key field values for selected items
 
And set the ClientDataKeyNames if you want to access from client side.
Extracting key values client-side

I hope the documentations will be of help. In the case this does not help you, please paste the code that you tried.


-Shinu.
0
Sean
Top achievements
Rank 1
answered on 01 Jul 2010, 01:13 PM
Shinu,

Thank you so much, You were correct I had missed the DataKeyNames.

But what is the correct way to retreive all the other pieces in the data grid? Is it the Cells property?

Thanks.
0
Princy
Top achievements
Rank 2
answered on 01 Jul 2010, 01:40 PM
Hello,

Accessing cell values can be accomplished using the getCellByColumnUniqueName method of the GridTableView client-side object. This method takes two parameters: a row object and the UniqueName of a column. It returns the corresponding cell from the grid table.

Go through doc to know more about this: Getting cell values for selected rows client side


Thanks,
Princy.
0
Sean
Top achievements
Rank 1
answered on 01 Jul 2010, 02:16 PM
Princy,

Im looking for server side code, not client.

But my original question was answered, so I will do some more research on my second questions.

Thanks to you both for the information you have supplied.
0
Shinu
Top achievements
Rank 2
answered on 05 Jul 2010, 12:21 PM
Hello,

Because of features such as column reordering and grouping, the index of individual columns can change on the client. This means that using indexes to access individual cells in the Cells collection of a row is not a reliable method of obtaining a cell in a particular column.

To provide a reliable way of locating the cell in a particular column, each column in the grid has a UniqueName property of type string.

 
 string itemValue = dataItem["ColumnUniqueName"].Text; //where dataItem is object of type GridDataItem   

Also the documentation shows example for accessing cells in grid.
Accessing cells and rows


-Shinu.
Tags
Grid
Asked by
Sean
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sean
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or