-
textbox value
In my wpf application, there is a listbox a several textboxes.
On clicking an item in the listbox, the textboxes are populated accordingly.
Do you know why the following happens?
select an item in the listbox.
textboxes are populated with other fields for the selected item. Let's say textbox1 has an empty value.
Type "hello" in the textbox.
select another item from the listbox.
Now in the listbox, select the original item you selected. the textbox has the value "hello".
If application is closed and re-opened then obviously the word "hello" is not there.
Do you see why the value is retained eventhough the data is not saved into the database?
Thanks
-
Re: textbox value
Maybe because there is no update statement/command?
-
Re: textbox value
Because a TextBox binding defaults to TwoWay, meaning any changes you make in the TextBox get pushed back to the bound property. You have two choices if you don't want that behaviour. Firstly, specify a Mode of OneWay on the Binding. Secondly, use a TextBlock or Label which default to OneWay and don't have editing capabilities (it would seem odd to have an editable TextBox that doesn't save any changes you make)