How do i access BindingSource current row and change value of specific field ?
I have client table with 4 elements
client_guid
code
name
surname
My form is binded through BindingSource to all fields except client_guid
I want to create new client. So i enter values in all fields and hit save. But i get error that client_guid should be supplied.
I use BindingSource.AddNew() and then i use BindingSource.EndEdit() to save new clients- this works fine and new row is created, but it works only if i also bind client_guid to some textbox... sure it is not what i want. I wan to assign client_guid value in code not from UI textbox
I can't get it how do i access this client_guid field to set it's value. I would do it before calling EndEdit()
i thought i can access it like BindingSource.Current, but there are no methods for that. Then i thought maybe i should set value directly in DataSet but that does not work either - it says there are no rows at position 0.
This is code in short:
physicalPersonBindingSource.DataSource =
CommonData.MainDataManager.DataSetCR.PhysicalPerson;
physicalPersonBindingSource.AddNew();
textBoxCode.DataBindings.Add("Text", physicalPersonBindingSource, "code", true, DataSourceUpdateMode.OnPropertyChanged, String.Empty);
textBoxName.DataBindings.Add(
"Text", physicalPersonBindingSource, "name", true, DataSourceUpdateMode.OnPropertyChanged, String.Empty);
textBoxSurname.DataBindings.Add(
"Text", physicalPersonBindingSource, "surname", true, DataSourceUpdateMode.OnPropertyChanged, String.Empty);
physicalPersonBindingSource.EndEdit();