Hello,
I have a dataset containing two tables. One of the tables is the Customer table and the other one is the customer Purchases table. They have a one to many relationship; each customer can have more than one purchases.
I can't get the RadTreeView to dispay anything related to the Customer or Purchases. They only thing the TreeView displays is the following: System.Data.DataViewManagerListTypeDescriptor. That looks like an error message!?
What am I doing wrong?
I've been struggling with this for an entire day; trying anythign under the sun.
I am using the newest RadTreeView control.
My datbase tables look as follows:
Customer table
====================
ID (autoincrement unique ID)
CustomerName
Purchases table
=============
PurchasesID (autoincrement unique ID)
Customer_ID (foreign key to ID in Customer table)
In the tree view, the customer's purchases should show up underneath each customer's name.
Here is my code:
Please help.
Thank you!
I have a dataset containing two tables. One of the tables is the Customer table and the other one is the customer Purchases table. They have a one to many relationship; each customer can have more than one purchases.
I can't get the RadTreeView to dispay anything related to the Customer or Purchases. They only thing the TreeView displays is the following: System.Data.DataViewManagerListTypeDescriptor. That looks like an error message!?
What am I doing wrong?
I've been struggling with this for an entire day; trying anythign under the sun.
I am using the newest RadTreeView control.
My datbase tables look as follows:
Customer table
====================
ID (autoincrement unique ID)
CustomerName
Purchases table
=============
PurchasesID (autoincrement unique ID)
Customer_ID (foreign key to ID in Customer table)
In the tree view, the customer's purchases should show up underneath each customer's name.
Here is my code:
private void frmMain_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); DataRelation relation; string connectionString = "server=MYSQLSERVER;database=MyStore;uid=FakeUserID;pwd=FakePassword"; SqlConnection mySqlConnection = new SqlConnection(connectionString); string strCustomer_Query = "Select * from Customer"; string strPurchases_Query = "Select * from Purchases"; try { SqlCommand sql_Customer = new SqlCommand(strCustomer_Query, mySqlConnection); SqlDataAdapter da = new SqlDataAdapter(sql_Customer); da.Fill(ds, "Customer"); da.SelectCommand.CommandText = strPurchases_Query; da.Fill(ds, "Purchases"); // Add the relation. Maybe this is not needed because we use the RelationBindings of the RadTreeView DataColumn parentCol = ds.Tables["Customer"].Columns["ID"]; DataColumn childCol = ds.Tables["Purchases"].Columns["Customer_ID"]; relation = new DataRelation("Customer_Purchases", parentCol, childCol); ds.Relations.Add(relation); treeView1.ShowLines = true; treeView1.RelationBindings.Add(new RelationBinding(ds, "CustomerName", "Customer_ID", "PurchaseID", "ID")); treeView1.DataSource = ds; treeView1.DisplayMember = "CustomerName"; treeView1.ValueMember = "ID"; treeView1.ParentMember = "ID"; treeView1.ChildMember = "PurchaseID"; treeView1.ExpandAll(); }Please help.
Thank you!