Simple Data Binding to Multiline Textbox

SaintJimmy

Member
Joined
Jul 7, 2006
Messages
24
Programming Experience
5-10
I've got 2 controls on a form... a DataGridView and a TextBox.

The DataGridView is bound to a BindingSource object, which I'll call MyBindingSource, which is bound to a DataSet. I'm handling the CurrentItemChanged event for MyBindingSource, and in the handler I call a function of a TableAdapter called FillByID, which is passed the value of the ID field of the currently selected item in the DataGridView. This action fills a table in my DataSet with the only record (if any) corresponding to that ID. That table is bound by another BindingSource object, and the Message field is bound to the Text property of the TextBox control.

The problem comes in when I edit the text. It's supposed to submit the changes to the DataSet on validation, but this is apparently not happening. After validation happens on the TextBox, I call HasChanges on the DataSet, and it returns false.. every time without fail.

What's going wrong? It's probably something really simple.
 
I'll assume youre doing:

MessageTA.FillByID(MessageDataSet.MessageDataTable, 123)


Do you then call MessageBindingSource.EndEdit() during the validation of the textbox? WIthout this call, no changes will be sent back to the dataset's table.


Please note that Bindingsources arent bound to datasets alone, they are bound to datatables within a dataset either by direct bind, or by bind to the dataset and setting of the datamember string to be the name of the table.. In all cases when communicating with other programmers you should not indicate that you fill, update, search or perform any similar DataTable-esque actions on a DataSet. i.e. Make clear in your mind the distinction between a DataSet (a group of related/relatable DataTables) and a DataTable, and use the correct term of reference. :)
 
Back
Top