Link to home
Start Free TrialLog in
Avatar of NWSITSupport
NWSITSupportFlag for United States of America

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_SelectedIndexChanged(object sender, EventArgs e)
        {
           
            if (SaleTypecomboBox.SelectedValue.ToString().Equals("16"))
            {
                DataRowView currentRow = (DataRowView)bindingSource1.Current;
                DataRow dr = dtRunsheet.NewRow();

                dr["acct_AccountingRunsheetID"] = -1;
                dr["acct_SittingID"] = (int)currentRow.Row["acct_SittingID"];
                dr["acct_BookingID"] = _bookingID;
                dr["acct_ChildFirstName"] = currentRow.Row["acct_ChildFirstName"].ToString();
                dr["acct_ParentFirstName"] = currentRow.Row["acct_ParentFirstName"].ToString();
                dr["acct_ParentLastName"] = currentRow.Row["acct_ParentLastName"].ToString();
                dtRunsheet.Rows.Add(dr);
               
                bindingSource1.ResetBindings(false);

                bindingSource1.DataSource = dtRunsheet;
                bindingSource1.Sort = "acct_SittingID";
               
           }
        }

Does anyone know what I'm leaving out?
Thanks,
Faith
ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NWSITSupport

ASKER

Sounds sort of like what I need, but can you provide some sample code?
Needed some code example to help, but the link that was provided allowed me to move in the right direction.