By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

Bound Grids Not Working Correctly

P: n/a
I'm having trouble trying to get some bound datagrids to work. I even tried
to use some examples that were given to me, but I can't get those to work,
either.

I have customers, who have orders, which have order details. The order
details also use a product lookup table, to get description, etc., and this
seems to be the problem table. Customer -> Order is a 1:m relationship, Order
-> OrderDetails is a 1:m relationship, but the OrderDetails -> Product is a
m:1 relationship.

Here is my code that I'm using (It goes into the Form_Load event). The first
3 grids populate and work well together, as I navigate through them. The 4th
grid is blank, and stays that way. Flex1,2,3,4 are Flexgrids from Component1,
but they work the same with Microsoft's grids, too.

Can anybody tell me what I'm doing wrong, and how to make it work properly?
Thanks in advance.

Dim drc As DataRowCollection
Dim dcc As DataColumnCollection
Dim ds As DataSet = New DataSet("Hierarchical Dataset")
ds.Tables.Add("Products")
dcc = ds.Tables("Products").Columns
dcc.Add("ID", GetType(String))
dcc.Add("Name", GetType(String))
dcc.Add("Value", GetType(Decimal))
drc = ds.Tables("Products").Rows
drc.Add(New Object() {"P1", "Widget", 19.95})
drc.Add(New Object() {"P2", "Gadget", 22.75})
drc.Add(New Object() {"P3", "Sprocket", 33.1})
ds.Tables.Add("Customers")
dcc = ds.Tables("Customers").Columns
dcc.Add("ID", GetType(String))
dcc.Add("Name", GetType(String))
dcc.Add("Address", GetType(String))
drc = ds.Tables("Customers").Rows
drc.Add(New Object() {"C1", "John", "122 Penny Lane"})
drc.Add(New Object() {"C2", "Paul", "646 Abbey Road"})
drc.Add(New Object() {"C3", "George", "222 Chatham Road"})
drc.Add(New Object() {"C4", "Ringo", "345 Oxford St"})
ds.Tables.Add("Orders")
dcc = ds.Tables("Orders").Columns
dcc.Add("ID", GetType(String))
dcc.Add("CustomerID", GetType(String))
dcc.Add("Prty", GetType(Integer))
dcc.Add("Date", GetType(DateTime))
drc = ds.Tables("Orders").Rows
drc.Add(New Object() {"O1", "C1", 1, "12/1/01"})
drc.Add(New Object() {"O2", "C2", 2, "1/22/02"})
drc.Add(New Object() {"O3", "C3", 3, "1/20/02"})
drc.Add(New Object() {"O4", "C4", 1, "1/14/02"})
drc.Add(New Object() {"O5", "C1", 3, "1/16/02"})
ds.Tables.Add("OrderDetail")
dcc = ds.Tables("OrderDetail").Columns
dcc.Add("ID", GetType(String))
dcc.Add("OrderID", GetType(String))
dcc.Add("ProductID", GetType(String))
dcc.Add("Qty", GetType(Integer))
drc = ds.Tables("OrderDetail").Rows
drc.Add(New Object() {"D1", "O1", "P1", 1})
drc.Add(New Object() {"D2", "O1", "P2", 12})
drc.Add(New Object() {"D3", "O1", "P3", 1})
drc.Add(New Object() {"D4", "O2", "P1", 1})
drc.Add(New Object() {"D5", "O2", "P2", 8})
drc.Add(New Object() {"D6", "O2", "P3", 1})
drc.Add(New Object() {"D7", "O3", "P1", 1})
drc.Add(New Object() {"D8", "O4", "P1", 1})
drc.Add(New Object() {"D9", "O4", "P2", 10})
drc.Add(New Object() {"D10", "O5", "P1", 1})
drc.Add(New Object() {"D11", "O5", "P2", 16})
drc.Add(New Object() {"D12", "O5", "P3", 1})
ds.Relations.Add("CustomerOrders",
ds.Tables("Customers").Columns("ID"),
ds.Tables("Orders").Columns("CustomerID"))
ds.Relations.Add("Order Details", ds.Tables("Orders").Columns("ID"),
ds.Tables("OrderDetail").Columns("OrderID"))
ds.Relations.Add("Product Details",
ds.Tables("Products").Columns("ID"),
ds.Tables("OrderDetail").Columns("ProductID"))

flex1.DataMember = "Customers"
flex1.DataSource = ds
flex2.DataMember = "Customers.CustomerOrders"
flex2.DataSource = ds
flex3.SetDataBinding(ds, "Customers.CustomerOrders.Order Details")
flex3.DataSource = ds
Flex4.SetDataBinding(ds, "Customers.CustomerOrders.Order
Details.Product Details")
Flex4.DataSource = ds

Feb 28 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.