views:

446

answers:

2

I have an ADO.NET Entity Data Model and want to plumb up a DataGridView for CRUD operations. How should I go about this?

For a read-only DataGridView I've been doing the following

TimeTrackEntities tte = new TimeTrackEntities();  //Entity Data Model
ObjectQuery<Days> DayQuery = tte.Days;
dgvDays.DataSource = DayQuery;
A: 

There's a walk-through here.

Note:

There are a few more steps to actually getting user interaction with this. You need to populate the Binding Source and if you want to edit, you'll need to add a little code to the save button on the toolbar.

You'll need to enable the BindingNavigatorSaveButton (just click the save icon on the navigator toolbar and change it's Enabled property to True). Additionally, you'll probably want to format the grid which you can do easily from it's SmartTag and more thoroughly through the properties window.

Craig Stuntz
@Craig: I reviewed the walk-though. It said to add/enable the save button, but doesn't provide the coded needed for it's click event.
Chad
A: 

I've read that most people use LINQ To Entities for working w/ EF in the context of a data source for data grids.

Would be nice if the new version would support an DataAdaper style update method. Here is a article on the new version coming of with .net 4 / VS2010.

Chad