Rank: Newbie Groups: Member
Joined: 6/13/2016 Posts: 1
|
I'm very new to your product.
I have two tables category and products. I want a tree view that allows user to drag products from a chosen category into a gridview.
Here is my code so far:
DataSet ds = new DataSet(); string s = "Select code, name From category "; DataTable master = GetData(s); master.TableName = "Category"; ds.Tables.Add(master); s = @"select catID, stockCode,Description,cost,suppID, 0 AS Qty from Products "; DataTable dtChild = GetData(s); dtChild.TableName = "product"; ds.Tables.Add(dtChild);
DataRelation dtRelation; DataColumn CatCol = ds.Tables["Category"].Columns["code"]; DataColumn prodCol = ds.Tables["Product"].Columns["catID"];
dtRelation = new DataRelation("CatProdRelation", CatCol, prodCol); ds.Tables["Product"].ParentRelations.Add(dtRelation); dtRelation.Nested = true;
TreeView1.DataSource = ds; TreeView1.DataBind();
<eo:TreeView ID="TreeView1" runat="server" Height="250px" Width="200px" > <TopGroup Style-CssText="border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:2px;padding-left:2px;padding-right:2px;padding-top:2px;"> <Bindings> <eo:DataBinding DataField="code" Property="Value" ></eo:DataBinding> <eo:DataBinding DataField="description" Property="Text" ></eo:DataBinding> </Bindings> </TopGroup> <LookNodes> <eo:TreeNode ItemID="_Default"> </eo:TreeNode> </LookNodes> </eo:TreeView>
Obviously this is not working - the error is "code does not belong to table product"
Thank you Simon
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,203
|
Hi,
Have you tried to add dtRelation to ds.Relations? You can take a look of the sample code in EOWebDemo -> Demos -> Menu -> Data Binding -> Populate from DataSet for a working example of populating hierarchical data from data set.
Thanks!
|