扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
Public Function GetTreeTable() As DataTable Dim dt As New DataTable() dt = HttpContext.Current.Cache("Treeview") If dt Is Nothing Then Dim Conn As New SqlConnection Dim clsConnDatabase As New ConnectionDatabase Conn = clsConnDatabase.ConnDatabase Dim Command As New SqlCommand Command.Connection = Conn Command.CommandText = "GetTreeview" Command.CommandType = CommandType.StoredProcedure Command.ExecuteNonQuery() Dim da As New SqlDataAdapter(Command) dt = New DataTable() da.Fill(dt) HttpContext.Current.Cache.Insert("Treeview", dt) End If Return dt End Function 这里是主要阿 Public Sub PopulateNodes(ByVal nodes As TreeNodeCollection, Optional ByVal intParentID As Int32 = 0) Dim dt As New DataTable() dt = clsWebForms.GetTreeTable() Dim strExpression As String strExpression = "[parentID] = " & intParentID Dim foundRows() As DataRow foundRows = dt.Select(strExpression) Dim I As Integer For I = 0 To foundRows.GetUpperBound(0) Dim tn As New TreeNode() tn.Text = foundRows(I).Item(“TableName”).ToString() tn.Value = foundRows(I).Item("ID").ToString() Dim dr() As DataRow dr = dt.Select("[parentID] = " & tn.Value) If dr.GetUpperBound(0) > -1 Then tn.PopulateOnDemand = True End If nodes.Add(tn) Next End Sub 建立WebForm 放入Treeview Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then PopulateNodes(TreeView1.Nodes, 0) End If End Sub Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodePopulate PopulateNodes(e.Node.ChildNodes, e.Node.Value) End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者