Hi,
I need to bind a dataset to webdatatree. I am using the code attached to do the same. But it displays nodes as Infragistics.Web.UI.Framework.Data.DataSetNode.
We need to display data. I am using the below code in aspx page.
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="WebDataTree.aspx.vb" Inherits="WebDataTree" %>
<%@ Register Assembly="Infragistics4.Web.v13.1, Version=13.1.20131.2157, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"Namespace="Infragistics.Web.UI" TagPrefix="ig" %>
<%@ Register Assembly="Infragistics4.Web.v13.1, Version=13.1.20131.2157, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"Namespace="Infragistics.Web.UI.NavigationControls" TagPrefix="ig" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><html><head runat="server"><title>Web Data Tree</title><style type="text/css">.SelectedNodeCSS {color:White;background-color:#1B8ACC;padding:2px;}.NodeCSS{padding:2px;}.HoverCSS{padding:2px;}</style></head><%--<ClientEvents NodeClick="NodeClickHandler" SelectionChanged="NodeSelectionChangedHandler" />--%><body id="body" runat="server" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0"><form id="form1" runat="server"><div><ig:WebScriptManager ID="WebScriptManager1" runat="server"></ig:WebScriptManager><ig:WebDataTree ID="WebDataTree1" runat="server" Font-Size="8pt" Font-Names="Verdana,Tahoma" Height="600px" Width="400px"EnableCheckBoxes="true" EnableTriStateCheckBoxes="true" CheckBoxMode="TriState" EnableAjax="true" SelectionType="Single"InitialDataBindDepth="1" InitialExpandDepth="0">
<NodeSettings SelectedCssClass="SelectedNodeCSS" CssClass="NodeCSS" HoverCssClass="HoverCss" /></ig:WebDataTree></div></form></body></html>
The vb page is as below
Imports SystemImports System.DataImports System.ConfigurationImports System.CollectionsImports System.WebImports System.Web.SecurityImports System.Web.UIImports System.Web.UI.WebControlsImports System.Web.UI.WebControls.WebPartsImports System.Web.UI.HtmlControlsImports System.Data.SqlClientImports System.Data.OleDbImports Infragistics.Web.UI.NavigationControls
Partial Public Class WebDataTree : Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)body.Style.Add("overflow", "hidden")If Not IsPostBack ThenDim data As DataSet = GetData()Dim binding As DataTreeNodeBinding = New DataTreeNodeBinding()binding.DataMember = "OrderID"binding.TextField = "OrderID"binding.ValueField = "OrderID"WebDataTree1.DataBindings.Add(binding)WebDataTree1.DataSource = dataWebDataTree1.DataBind()End IfEnd Sub
Private Function GetData() As DataSet
Dim connString As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Nwind.mdb;Persist Security Info=True")
'Dim connString As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
Dim selectEmploeyeesSql As String = "SELECT * FROM ORDERS"Dim selectEmployeeTerritoriesSql As String = "SELECT * FROM [ORDER DETAILS]"
Dim data As New DataSet()
Dim tableTest As New DataTable("Test")tableTest.Columns.Add("Id", GetType(Integer))tableTest.Columns.Add("Text", GetType(String))
tableTest.Rows.Add(1, "test 1")tableTest.Rows.Add(2, "test 2")
Dim adapter As New OleDbDataAdapter(selectEmploeyeesSql, connString)Dim tableEmploeyees As New DataTable("ORDERS")adapter.Fill(tableEmploeyees)
tableEmploeyees.PrimaryKey = New DataColumn() {tableEmploeyees.Columns("ORDERID")}
adapter = New OleDbDataAdapter(selectEmployeeTerritoriesSql, connString)Dim tableEmployeeTerritories As New DataTable("ORDERDETAILS")adapter.Fill(tableEmployeeTerritories)
data.Tables.Add(tableTest)data.Tables.Add(tableEmploeyees)data.Tables.Add(tableEmployeeTerritories)
Dim parentColumn As DataColumn = tableEmploeyees.Columns("OrderID")Dim childColumn As DataColumn = tableEmployeeTerritories.Columns("OrderID")
data.Relations.Add(parentColumn, childColumn)
Return dataEnd FunctionEnd Class
Kindly suggest me display the data in the nodes.
Hello sucheendarnath,
Please do not hesitate to contact me if you are still experiencing issues with this scenario.
TheDataMemberproperty of WebDataTree's databinding object relates to the table in the data source which contains the fields used for the binding. In this case therefore its value should be "ORDER". Note that the datamember/text and value key properties are case sensitive and judging by how the columns are defined in the DataTable, the values for the text and value key properties in this case should be "ORDERID".
Hope this helps. Please feel free to contact me if you have any questions.