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

Retrieve bound entity [row] from gridview using entity framework

1 Answer 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 2
Bob asked on 15 Nov 2012, 10:16 PM
Wondering if there is a simple way to do this...

I add an object to my entity context but I have not saved changes yet.  Therefore there is no ID or key associated to the entity.
I do however bind the grids datasource to the entities context.  The data appears in the grid in the appropriate file.

However, if I want to modify or delete a row whereas the entity hasn't been saved, I can't execute a LINQ query or something to get the record; again because it hasn't been saved yet.

Is there a way to get and assign the entity based upon the row selected?

dim detail as Invoice_Detail = gridview.selectedrow(0)....  Or something to that extent.

Thanks
Bob

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 20 Nov 2012, 02:29 PM
Hi Bob,

To support Winforms binding to EntityFramework object you must use the Local property of your DBSet object and convert the result ToBindingList. Using this approach you will support full CRUD stack in RadGridView and then you can save your changes after edit operations in the back-end MS SQL Server database or other storage. Please view the attached example for details.

More information about this topic you can find in this blog post.

I hope this helps.

Greetings,
Julian Benkov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
Bob
Top achievements
Rank 2
Answers by
Julian Benkov
Telerik team
Share this question
or