textBox DataBindings not working?

  • Thread starter Thread starter jose.mendez22
  • Start date Start date
J

jose.mendez22

In my code I create a sqlDataAdapter that which contains a simple
select command using the Northwind DB (SELECT top 15 customerID,
companyName, contactName, contactTitle From Customers). I populate the
dataSet using the fill and bind the dataset to a datagrid. I then bind
a text box control to a field on my dataset. When I move around the
datagrid my textbox control values does not change. It the value stays
on the first record. If anyone could provide any suggestions as to
what I'm doing wrong I would greatly appreciate it.

this.daNorthWind.FillSchema(this.dsCustomer,SchemaType.Source,
"Customers");
this.daNorthWind.Fill(this.dsCustomer,"Customers");
this.dataGrid1.DataSource = new
DataView(this.dsCustomer.Tables["Customers"]);

this.txtCustomerID.DataBindings.Add("Text",this.dsCustomer.Tables["Customers"],
"customerID"

Thanks
 
Hey jose,

The way you are trying to present data does not work in web environment..
say you display 100 items in datagrid and you bind customer id to textbox
and you wish to display id in textbox for each client side move.. does not
work. Can you tell how did you move around with your datagrid? did you click
on any button?

Hope this would clarify..
 
I did this sample on a win. form. app. I also noticed when I re-wrote
the datasouce assignment to only include the dataset (no dataview) it
worked correctly (see below)? Q: when i assign a dataview to the
datasource if I want to get the current values for a row do I have to
use the concurrency obj?
,,,
this.dataGrid1.DataSource = dsCustomer
this.txtCustomerID.DataBindings.Add("Text",this.dsCustomer.Tables["Customer­s"],

"customerID"
 
Back
Top