wpf - How to automatically update TableAdapter bound to TextBox -
I have a WPF window with several text boxes on it.
I have an XSD dataset attached to SQL server database, and window table-adapter is limited to one line:
public partial class PersonForm: window {public person (Int id) {InitializeComponent (); MyDatasetTableAdapters.personTableAdapter tableAdapter = New MyDatasetTableAdapters.personTableAdapter (); Person line line = table adapter. Getpsonsby ID; this. DataContext = Row; } ...
The text boxes are bound to:
I have a button, when the call is clicked
myTableAdapter.Update (myRow);
This successfully updates SQL database.
My question is: What changes do I need to do this so that the text box automatically updates the database automatically (without table adapter. to do).
In addition, is it a proper way to bond a form to a database in WPF?
I have found a way to accomplish this.
NotifyOnSourceUpdated set the property to True on text box binding like this:
& lt; Text box name = "last name" text = "{binding path = last name, notification source update = true}" />
I am able to update the table adapter in the source updated event of the window:
Private Zero Windows_SourceUpdated (Object Sender, DataTransferEventArgs e) {myTableAdapter. Update (myRow); }
Does it work well? Is this a better way to accomplish this?
Do all NotifyOnSourceUpdated Is there any way to enable it easily?
Comments
Post a Comment