NWSITSupport
asked on
BindingSource C#
Setup:
I have a DataGridView with a bindingsource set to a dataset.
Text boxes, combo boxes, etc are binded to the bindingsource.
If the user click on the datagridview row, the bindingsource populates the textboxes, etc.
Issue:
When the user changes the selectedvalue on a specific combobox and it equals 16, then I need to add a new row to my dataset/bindingsource.
I have a new row added to the dataset, shows in the datagridview, and count is updated in the bindingsource, but when I click to go through the rows in the bindingnavigator, when it gets to the new row, it stops. Sort of like it doesn't have information to load it.
Here's my code:
private void SaleTypecomboBox_SelectedI ndexChange d(object sender, EventArgs e)
{
if (SaleTypecomboBox.Selected Value.ToSt ring().Equ als("16"))
{
DataRowView currentRow = (DataRowView)bindingSource 1.Current;
DataRow dr = dtRunsheet.NewRow();
dr["acct_AccountingRunshee tID"] = -1;
dr["acct_SittingID"] = (int)currentRow.Row["acct_ SittingID" ];
dr["acct_BookingID"] = _bookingID;
dr["acct_ChildFirstName"] = currentRow.Row["acct_Child FirstName" ].ToString ();
dr["acct_ParentFirstName"] = currentRow.Row["acct_Paren tFirstName "].ToStrin g();
dr["acct_ParentLastName"] = currentRow.Row["acct_Paren tLastName" ].ToString ();
dtRunsheet.Rows.Add(dr);
bindingSource1.ResetBindin gs(false);
bindingSource1.DataSource = dtRunsheet;
bindingSource1.Sort = "acct_SittingID";
}
}
Does anyone know what I'm leaving out?
Thanks,
Faith
I have a DataGridView with a bindingsource set to a dataset.
Text boxes, combo boxes, etc are binded to the bindingsource.
If the user click on the datagridview row, the bindingsource populates the textboxes, etc.
Issue:
When the user changes the selectedvalue on a specific combobox and it equals 16, then I need to add a new row to my dataset/bindingsource.
I have a new row added to the dataset, shows in the datagridview, and count is updated in the bindingsource, but when I click to go through the rows in the bindingnavigator, when it gets to the new row, it stops. Sort of like it doesn't have information to load it.
Here's my code:
private void SaleTypecomboBox_SelectedI
{
if (SaleTypecomboBox.Selected
{
DataRowView currentRow = (DataRowView)bindingSource
DataRow dr = dtRunsheet.NewRow();
dr["acct_AccountingRunshee
dr["acct_SittingID"] = (int)currentRow.Row["acct_
dr["acct_BookingID"] = _bookingID;
dr["acct_ChildFirstName"] = currentRow.Row["acct_Child
dr["acct_ParentFirstName"]
dr["acct_ParentLastName"] = currentRow.Row["acct_Paren
dtRunsheet.Rows.Add(dr);
bindingSource1.ResetBindin
bindingSource1.DataSource = dtRunsheet;
bindingSource1.Sort = "acct_SittingID";
}
}
Does anyone know what I'm leaving out?
Thanks,
Faith
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Needed some code example to help, but the link that was provided allowed me to move in the right direction.
ASKER