I have a WPF Window with several TextBoxes on it.
I have an XSD dataset attached to a SQL server database, and the window is bound to a row from the tableadapter:
public partial class PersonForm : Window
{
public PersonForm(int id)
{
InitializeComponent();
MyDatasetTableAdapters.personTableAdapter tableAdapter =
new MyDatasetTableAdapters.personTableAdapter();
personRow row = tableAdapter.GetPersonById(id);
this.DataContext = row;
}
...
}
The textboxes are bound like this:
<TextBox Name="lastName" Text="{Binding Path=lastname}" />
These binding bindings work and the text boxes are populated with the data from the SQL database properly, but when the text box is edited, the changes are not propogated back to the database.
I have a button that when clicked calls
myTableAdapter.Update(myRow);
This does successfully update the SQL database.
My question is: What changes do I need to make so that the text boxes will automatically update the database automatically (without having to explicitly call TableAdapter.Update).
Also, is this the proper way to bind a form to a database in WPF?