help with DataTable.AcceptChanges()

hi all.

in my code i wrote:

dataview MyDv=new Dataview(MyDataTable);

MyDv["SomeColumn"]="xxx";

and here i enter a new row directly to MyDataTable:

Datarow DrNew=MyDatatable.NewRow();

DrNew["Column"]=xxx;

MyDataTable.Rows.Add(DrNew);

do i have to use MyDataTable.AcceptChanges() to get the changes i enterd in the MyDv Before i add a new row

do i have to use Mydv.BeginUpdate() and EndUpdate() before i change it's data




Answer this question

help with DataTable.AcceptChanges()

  • ddCONFUSED

    Hello, shimshon

    MSDN description of the method is so clear, here share with you all: http://msdn2.microsoft.com/en-us/library/system.data.datatable.acceptchanges.aspx

    Hope to make it clearer.

    Thank you



  • crescens2k

    No your code for adding a new looks good.

    When you add a new row it's RowState property will be Added, etc.... The AcceptChanges() method changes the RowState of all rows to Unchanged. You don't need to call this before you add any row. It's use is for validation, rollback, pushing changes back to the database, etc

    To update your dataView, perhaps try setting the DataSource property again or use a bindingSource instead of linking the datatable directly with the datagridview..


  • prestorm

    AcceptChanges() marks all rows as Unchanged. If you add row, call AcceptChanges and call dataAdapter's Update method you wont get new row in underlying datasource.

    hope this helps

    P.S. If you need more info it would be better to describe what are you trying to achieve.



  • help with DataTable.AcceptChanges()