cannot update datatable or dataset when binding with textboxes in VS.NET 2005 with C#

Sep 13 2007 4:44 AM

Hi there...

im working in Visual Studio.NET 2005 and C#, i have binded two text boxes with dataTable named dt.
        
textbox1.Databindings.Add("text", dt, "customerName");
textBox2.Databinding.Add("Text", dt, "billNo");

Here customerName, billNo is the feildName in the table name customer.

This binding works fine. When i run the application i see the values from the first row in the table.

I can also perform navigation, if i bind the datatable with the BindingSource object and then calling its moveFirst(), moveLast() methods.

BindingSource bindingSrc = new BindingSource();
bindingSrc.DataSource = dt;

it also Works fine;

NOW, when it comes to updating. nothing works

for updating i have tried the following methods but does'nt work;

1)
textBox1.DataBindings.Add("text", bindingSource, "customerName");

textBox2.DataBindings.Add("text", bindingSource, "billNo");

 

da.Update(dt);

 This did not worked

2)

textBox1.DataBindings.Add("text", dt, "customerName");

textBox2.DataBindings.Add("text", dt, "billNo");

 

and in save button event:

da.Update(dt);

This also did not worked.

I tried doing updating in VS.NET 2003 C# it worked perfectly, and the same code does not work in VS.NET 2005.

I am trying for several days now, but could'nt fix this problem.

I want to ask that if there is any problem in vs.net 2005 or the method of binding and updating through text boxes is different in vs 2005. please tell.

I will be very greateful if some body try an example in 2005 and send me in my email: [email protected]

Thanks for reading such a leangthy problem. but plz help

 


Answers (2)