Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
540
Regarding displaying data in nodes
posted

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 System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports 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 Then
Dim 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 = data
WebDataTree1.DataBind()
End If
End 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 data
End Function
End Class

Kindly suggest me display the data in the nodes.