Home Forums WPF controls Xceed DataGrid for WPF Updating DataSource

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #22458 |

    Hi
    I am binding the datagrid using collectionview source. After insertion of new row in the datagrid or editing an existing row,how to update the actual datasource(northwind sql table).
    I tried getchanges() on the datatable and tried updating using dataadapter but it is throwing exception. Pls help.

    // Xaml DataGrid
    <xcdg:DataGridControl x:Name=”grid”
    ItemsSource=”{Binding Source={StaticResource sortedEmployees}}”
    >

    //Xaml Sorted Employees collection view source

    <CollectionViewSource x:Key=”sortedEmployees”
    Source=”{Binding Source={x:Static Application.Current},Path=Employees}”>
    <CollectionViewSource.SortDescriptions>
    <compModel:SortDescription PropertyName=”LastName”/>
    </CollectionViewSource.SortDescriptions>
    </CollectionViewSource>

    Note: path=Employees. Employees is a public datatable(data from northwind employee database) defined in app.cs.

    //Employees table

    SqlConnection sqlConn = new SqlConnection(sqlconStr);
    DataSet ds = new DataSet();
    sqlConn.Open();
    SqlDataAdapter sqlAdap = new SqlDataAdapter(“select * from employees”, sqlConn);
    sqlAdap.Fill(ds, “Employees”);
    Employees=ds.Tables[“Employees”];

    Thanks
    Guru

    Imported from legacy forums. Posted by guru rajan (had 2419 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Guru,

    To commit the changes on your database you should call the .AcceptChanges() method on your Employees DataTable as follow:

    Employees.AcceptChanges();

    Imported from legacy forums. Posted by Mohamed [Xceed] (had 602 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.