ChrisBirmele

I am trying to update a dataset row value via a binding source. The code below runs ok but does not update the actual dataset row. This is the code I tried:

DataRowView currentRow= (DataRowView)bindingSource1.Current;

currentRow.Row.ItemArray.SetValue(1234, 1);

and I tried this as well (same result)....

DataRow currentRow = ((DataRowView)bindingSource1.Current).Row;

currentRow.ItemArray[1] = 23;

Appreciate any help!

Regards Chris




Re: Windows Forms Data Controls and Databinding Updating a dataset via a binding source

Gavin Jin - MSFT

HiŁ¬please check following code

Code Snippet

private void tableBindingSource_AddingNew(object sender, AddingNewEventArgs e)
{
BindingSource bs = (BindingSource)sender;
DataView view = (DataView)bs.List;
DataRowView row = view.AddNew();
row["id"] = Guid.NewGuid();
if (bs.Count == 1)
{
bs.EndEdit();
}
bs.MoveLast();
e.NewObject = row;
}

With Regards