Click to See Complete Forum and Search --> : Binding in 1 direction only (control to dataset)


hanct
March 29th, 2009, 02:14 AM
Hi,

I am using form 2.0 to create a form in visual studio 2008. In this form, there is a textbox. I bind this textbox to a datatable , which will be populated by the data in the sql server database, when the form is launched.


Now here is the problem. I want my textbox to be empty initially, so that when user enter a value and press the save button, the value in the textbox will goes into the datatable.

But whenever I launch my form, my textbox always get populated by some value (I am not suprise since my textbox is binded to a datatable's column).

So question is how to I make my textbox empty initially while it is still bind to the datatable?

Shuja Ali
March 29th, 2009, 06:48 AM
The solution is pretty simple. Don't bind the datatable. The better way would be to add the record to the datatable manually once the user presses save button. Another option is to write the insert query for inserting data into database directly.

hanct
March 29th, 2009, 09:48 AM
Thanks! Adding record to the datatable manually is ok if there is only a few control. if I have 100s of controls , I have to add them manually....quite tedious. If only visual studio have a way to bind these controls to the dataset in 1 direction (from control to dataset) with a few click of mouse, how good would that be...

Shuja Ali
March 29th, 2009, 10:08 AM
Thanks! Adding record to the datatable manually is ok if there is only a few control. if I have 100s of controls , I have to add them manually....quite tedious. If only visual studio have a way to bind these controls to the dataset in 1 direction (from control to dataset) with a few click of mouse, how good would that be...
I am not aware of any way of binding the controls to a dataset/datatable in just one way.

hanct
March 30th, 2009, 06:54 AM
ok. Thanks. ;) Hope someone is aware of such method..if it ever exists.