WPF C# ListView Dataset, how do I update database with changes user makes to the data in the listview? -
Then I've created a list view using a dataset, i.e. selecting the ListView option for the table in the data source window and By dragging it on my interface
Each column has a mode for binding (dove / oneway etc). They were all set to double, i.e. this is a snippet of my list view in XML file:
& Lt; Setter Property = "Control. Vertical Content Element" Value = "Statch" /> & Lt; / Style & gt; & Lt; /ListView.ItemContainerStyle> & Lt; ListView.View & gt; & Lt; GridView & gt; & Lt; GridViewColumn x: name = "_ idColumn" header = "id" width = "60" & gt; & Lt; GridViewColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text box margin = "10, -1, -6, -1" text = "{binding_id, mode = wienz}" /> & Lt; / DataTemplate & gt; & Lt; /GridViewColumn.CellTemplate> & Lt; / GridViewColumn & gt; & Lt; GridViewColumn x: name = "company_nameColumn" header = "company name" width = "120" & gt; & Lt; GridViewColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text box margin = "- 6, -1" text = "{binding company_name, mode = dawa, notifications invalidity_ar = true, validity = true}" /> & Lt; / DataTemplate & gt; & Lt; /GridViewColumn.CellTemplate> & Lt; / GridViewColumn & gt; & Lt; GridViewColumn x: name = "Contact_name column" header = "contact name" width = "120" & gt; & Lt; GridViewColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text box margin = "- 6, -1" text = "{binding contact_name, mode = dawa, notifications validity error = truth, validities exception = true}" /> & Lt; / DataTemplate & gt; & Lt; /GridViewColumn.CellTemplate> & Lt; / GridViewColumn & gt; For the remaining columns,
... and so on
I need this so that the user can edit rows in the list view, save and press the changes, and Changes can be saved in the database. I am thinking that what is 'double'? I tried to use the acceptet's method on Dataset, it does not look like:
cBDataSet.AcceptChanges (); CBDataSetcbTableTableAdapter.Fill (cBDataSet.cbTable); CbTableViewSource = ((System.Windows.Data.CollectionViewSource) (this.FindResource ("cbTableViewSource"))); CbTableViewSource.View.MoveCurrentToFirst ();
Anyone have any ideas? Not sure what I'm doing
thanks
Via:
The acceptance changes meet all the changes made on this dataset because it was loaded or the last time AcceptChanges was called.
It is very misleading, usually people usually use the word "commute", usually talk about databases, but MS in this case disturbances on verbose. Accept change is nothing for the underlying data collection, it only states that the current data are accepted that the current changes are accepted, and basically to clean the dirty flag and consider the current data up-to-date. And match the built-in store.
However, it outlines the general use of a dataset:
Invite the GetChanges method to create a second dataset, which only shows changes Data
Call the DataAdapter update method, passing the second dataset as an argument.
Invite the merge method to merge the changes from the second dataset first.
Invite changes to acceptance on the dataset. Alternatively, request to decline to discard changes.
This should take you on the right track.
Comments
Post a Comment