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

Accessing entity objects from LinqDataSource

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 29 Sep 2008, 10:57 AM
Hi,

my question is not directly related to RadGrid but maybe someone can help me anyway.
I am using a RadGrid which is bound to a LinqDataSource. The User is able to select/deselect items within the grid.
When the user clicks the submit button the selected items are saved. To achive this, the grid has an invidible column which holds the primary keys of the items listed in the grid. After submit a list with the selected keys is passed to a method which retrievs the corresponding objects via a Linq-Query and adds them to a relation.
Now, my question is: Is it possible to get the entity object from the LinqDataSource when the user clicks the select button in the grid? It would be much more convenient to work with the objects instead of id's.

Thank you in advance for your suggestions.
Robert

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 01 Oct 2008, 03:30 PM
Hi Robert,

Basically, you can get reference to the underlying source object for the respective grid row only in data-bound context (namely, inside the ItemDataBound handler of RadGrid). The same is true for the MS GridView control as far as I am aware.

Since the grid is not rebound when server or client selection occurs, you can either stick to the current approach with hidden column for the key field or use DataKeyNames/DataKeyValues to store/retrieve the key values from the selected rows. For more info on the second approach please review this help article.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or