1

I bind a datagridview from a linq query, but I don't know how to make it updated to database when users makes changes on the datagridview.

var q = from w in dowacodbEntities.worksheets
                    where w.ContractForm_id.Equals(g_ContractID)
                    orderby w.id
                    select new
                               {
                                   w.id,
                                   w.UnitPrice,
                                   w.LabourCost
                               };
            BindingSource bindingSource = new BindingSource(); // use bindingsource
            bindingSource.DataSource = q.ToList(); // convert linq query to bindingsource
            dataGridView1.DataSource = bindingSource; // add bindingsource to datagridview

p/s : I'm using C# winform

JatSing
  • 4,857
  • 16
  • 55
  • 65

1 Answers1

0

I think this is the same problem

WinForms DataGridView - update database

Community
  • 1
  • 1
huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99