Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Const connectionString As String = _
"Server=localhost;Integrated Security=True;Database=Northwind"
Sub Page_Load()
if NOT IsPostBack Then
PopulateNodes()
End If
End Sub
Sub PopulateNodes()
Dim dst As DataSet = GetTreeViewData()
for each masterRow As DataRow in dst.Tables("Categories").Rows
Dim masterNode As New TreeNode(masterRow("CategoryName").ToString())
masterNode.NavigateUrl = ("Default2.aspx?src=" & masterRow("CategoryName").ToString())
TreeView1.Nodes.Add(masterNode)
for each childRow As DataRow in _
masterRow.GetChildRows("Children")
Dim childNode As New TreeNode(childRow("ProductName").ToString())
childNode.NavigateUrl = ("Default2.aspx?src=" & childRow("ProductName").ToString())
masterNode.ChildNodes.Add(childNode)
next
Next
End Sub
Function GetTreeViewData() As DataSet
Dim con As SqlConnection = new SqlConnection(connectionString)
Dim dadCats As SqlDataAdapter = new _
SqlDataAdapter("SELECT * FROM Categories", con)
Dim dadProducts As SqlDataAdapter = new _
SqlDataAdapter("SELECT * FROM Products", con)
Dim dst As DataSet = new DataSet()
dadCats.Fill(dst, "Categories")
dadProducts.Fill(dst, "Products")
dst.Relations.Add("Children", _
dst.Tables("Categories").Columns("CategoryID"), dst.Tables("Products").Columns("CategoryID"))
return dst
End Function
</script>
<html>
<head>
<title>Master/Detail TreeView</title>
</head>
<body>
<form id="form1" runat="server">
<asp:TreeView
ID="TreeView1"
Runat="Server"
ShowExpandCollapse=true
ImageSet=Faq
ExpandDepth=0
/>
To modify the look of the control try editing the "ImageSet" property of the treeview control...<br><br>
You can also use the imageUrl attribute of the node to provide custom images for the treeview..
</form>
</body>
</html>