我希望这不是为时已晚=)我有一些作品在这里...
// Entity Data Model
private ManagerEntities context = new ManagerEntities();
// declare private member
private BindingList<Currency> lstCurrencies = null;
// on form load, load data and bind to DataGridView's DataSource
private void Form1_Load(object sender, EventArgs e) {
lstCurrencies = new BindingList<Currency>();
ObjectResult or = ((ObjectQuery)currencies).Execute(MergeOption.AppendOnly);
foreach (Currency c in or)
lstCurrencies.Add(c);
// dgMain is my DataGridView
dgMain.DataSource = lstCurrencies;
}
// this will save objects that have changed. You might want to add logic for newly created and deleted objects.
private void btnSave_Click(object sender, EventArgs e) {
context.SaveChanges();
}
又名贫民窟的道路,:)。希望有一种不太暴力的方法。这虽然不起作用,但因为我目前绑定到BindingSource。这导致网格被清除。 – Jaime 2011-01-23 17:29:35