Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
440
Saving Data to Database
posted

Hi

I'm binding the Ultrawingrid to collection (List<Products>) Now am modifying the values in grid (for eg: price) and i have a save button in the form.

when clicking the save button, the changes in the grid to be saved to the database. How can i achieve this for Collection.

(For DataSet it's working fine)

Regards

Sam

 

Parents
  • 37774
    Verified Answer
    posted

    Sam,

    There's nothing really built into the grid for saving back to a database.  In the case of the DataSet, it is the DataSet itself that maintains what has changed since the data was retrieved, and you use that to get what needs to be persisted back to the DB.  In the case where you're using a List (side note: I recommend using a BindingList instead), there is nothing that keeps track of what has changed since the grid was initiallly bound.  One solution would be to keep a flag in the grid's AfterRowUpdate event telling you that you need to persist a given row (and do the same for AfterRowsDeleted, AfterRowInsert, etc).  The other solution would be to derive your own List (or BindingList) and implement some sort of mechanism for determining what has changed (i.e. when individual properties in the Products class change, or when an item is added or removed to the list).

    -Matt

Reply Children
No Data