This is a migrated thread and some comments may be shown as answers.

Dataform won't update my database

1 Answer 105 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Moshik
Top achievements
Rank 1
Moshik asked on 23 Mar 2013, 07:46 AM
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;
            }
        }
    }

1 Answer, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 25 Mar 2013, 07:18 AM
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.

Tags
DataForm
Asked by
Moshik
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or