Search code examples
c#datagridviewbindingsource

Reset bindingsource of datagridview does not work


I have a dataset(data.xsd) retrieving data from database, a Bindingsourc(bs) from a table of this data.xsd and a datagridview(dgview) bounded to this bs

now when I insert or delete an item I call the ResetBinding function of bs but the dgview doesn't update by that:

     bs.ResetBinding(false);
     ((BindingSource)dgview.DataSource).ResetBindings(false);

Is there any way to fix that?


Solution

  • I found my problem

    the DataSource that I bound the bs to it should get the new data from database and then call ResetBinding() function:

    bstableAdapter.Fill(DataTable);
    bs.ResetBinding(false);