Master-Detail grids and Text Box will not work together (binding p
From: meerkat (meerkat_at_discussions.microsoft.com)
Date: 12/05/04
- Next message: meerkat: "Master-Detail Grids and TextBox together will not bind"
- Previous message: Phillip Engle: "failure of combobox to bind to DBNull"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 5 Dec 2004 06:51:02 -0800
Hello, I have been looking all over the web to find an answer to a hopefully
very simple problem
I have a couple of standard Master-Detail Datagrids of the type shown in
examples everywhere.
I have added a textbox that is supposed to display a field from the master
table.
I can EITHER get the textbox to work OR the Master-Detail datagrids, but not
both.
Hopefully all will become clear by looking at the following routine.
I will be extremely grateful if anyone can help.
Regards
Meerkat.
Private Sub Solution_One()
Dim ds As New DataSet
Dim daCustomers As SqlDataAdapter
Dim daOrders As SqlDataAdapter
Dim dv As DataView
Dim strConn As String = "Data Source=.;Integrated
Security=SSPI;initial catalog=NorthWind"
Dim conn As New SqlConnection(strConn)
Dim colParent As DataColumn
Dim colchild As DataColumn
daCustomers = New SqlDataAdapter("Select * from Customers", conn)
daOrders = New SqlDataAdapter("Select * from Orders", conn)
conn.Open()
daCustomers.Fill(ds, "Customers")
daOrders.Fill(ds, "Orders")
conn.Close()
colParent = ds.Tables("Customers").Columns("CustomerID")
colchild = ds.Tables("Orders").Columns("CustomerID")
'Create relationship
ds.Relations.Add("CustomerOrders", colParent, colchild)
gridOrders.DataSource = ds
gridOrders.DataMember = "Customers.CustomerOrders"
' I have two 'related' grids and a textbox
' I can get the grids to work BUT NOT the Textbox
' OR
' I can get the Textbox to work BUT NOT the grids
'Master-Detail works. Orders change when I click on Customer Table
'txtCompanyName DOES NOT work. Doesn't change when Customer Changes
gridCustomers.DataSource = ds
gridCustomers.DataMember = "Customers"
txtCompanyName.DataBindings.Add("Text", ds.Tables("Customers"),
"CompanyName")
''Master-Detail DOES NOT work. Orders DO NOT change when I click on
Customer Table
''txtCompanyName DOES work. Changes when Customer Changes
'gridCustomers.DataSource = ds.Tables("Customers")
'txtCompanyName.DataBindings.Add("Text", ds.Tables("Customers"),
"CompanyName")
End Sub
- Next message: meerkat: "Master-Detail Grids and TextBox together will not bind"
- Previous message: Phillip Engle: "failure of combobox to bind to DBNull"
- Messages sorted by: [ date ] [ thread ]