Results 1 to 3 of 3

Thread: How to do Dataset Changes

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    683

    How to do Dataset Changes

    I have a bindingsource called persDataBindingSource it is filled with personnel records and on the top of my form I have several textboxes that are bound to that bindingsource. I have a bindingnavigator that allows me to step through the bindingsource. I have another binding source (claimsBindingSource) that is filtered by the persons id selected in the top bindingsource and a dataset (dsClaims). ON my form I have a datagridview with its datasource set to claimsBindingSource. I also have textboxs, combos, datetimepickers, etc that correspond to one row on the datagridview and they are bound to the bindingsource too. If I move through the datagridview, the controls follow along. If I make a change to a row in the datagridview and then move to the next persons record, it fires this code:

    Code:
    private void persDataBindingSource_PositionChanged(object sender, EventArgs e)
            {
               
                if (dsClaims.HasChanges() || intChange == 1)
                {
                    DialogResult result = MessageBox.Show("You have made changes, do you wish to save them?", "Save changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (result == DialogResult.Yes)
                    {
                        Validate();
                        claimsBindingSource.EndEdit();
                        this.claimsTableAdapter.Update(dsClaims.Claims);
                        intChange = 0;
                    }
                    else
                    {
                        intChange = 0;
                    }
                }
            }
    If I make the change in the datagrid, I get prompted to save the change. IF I make the change in the textbox of the same column, it moves to the next record without being prompted. Anyone know why and how I can get it to ask? I have been trying to fix this all week with no progress. All help will be greatly appreciated.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    683

    Re: How to do Dataset Changes

    Amazingly enough, I stumbled across the answer myself. I added this code to my BindingComplete of my bindingsource


    Code:
            private void claimsBindingSource_BindingComplete(object sender, BindingCompleteEventArgs e)
            {
                if (e.BindingCompleteContext == BindingCompleteContext.DataSourceUpdate && e.Exception == null)
                    e.Binding.BindingManagerBase.EndCurrentEdit();
            }

  3. #3
    Lively Member
    Join Date
    May 2008
    Location
    Manila, Philippines
    Posts
    81

    Re: How to do Dataset Changes

    hi, i have also forms wherein textboxes were binding to a datasource(datatable).

    my problem is, i can't see any changes made. I am using the datatable.getChanges() and it always return a null value.
    i also check the datatable rows count and it has a row added but the getChanges() return a null value, what could be the cause?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width