Dataform won't update my database

2 posts, 1 answers
  1. Moshik
    Moshik avatar
    5 posts
    Member since:
    Mar 2013

    Posted 23 Mar 2013 Link to this post

    Hi,


    I have a DataForm that i am binding to ObservableCollection that IEditableObject implemented in it. everything is working as expected except it is not pushing the changes/additions to the database.
    my collection class look like this: ("tbl_Suppliers" is the table from the database, "Supplier" is the IEditableObject, AppdataclassDataContext is the LinqToSQL datacontext):

    class suppliersdatacontext
        {
            public  AppdataclassDataContext dataDC = new AppdataclassDataContext();
            private ICollectionView suppliersQur = null;
            public ICollectionView Suppliers
            {
                get
                {
                    if (this.suppliersQur == null)
                    {
                        ObservableCollection<Supplier> newSuppliers = new ObservableCollection<Supplier>();

                        foreach (tbl_Supplier thisSupplier in dataDC.tbl_Suppliers)
                        {
                            newSuppliers.Add(new Supplier ((int)(thisSupplier.SupplierID), thisSupplier.name, thisSupplier.country,    thisSupplier.contactperson, thisSupplier.contactemail, (decimal)(thisSupplier.discount)));
                            
                        }
     
                        this.suppliersQur = new QueryableCollectionView(newSuppliers);
                    }
                    return this.suppliersQur;
                }
            }
        }

  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 25 Mar 2013 Link to this post

    Hi Moshik,

    You need to extend the functionality of the form so that it submit the changes to the database. Since DataForm is not aware of the backend (what your database is, whether you are working with such, etc.), it cannot push the modifications to it. 
    What you can try for example is to extend the functionality of the Ok button so that it calls SubmitChanges() method for instance. Check out this article for a reference.

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top