All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
编写高性能Web应用程序的10个技巧_[Asp.Net教程]
Delphi窗格组件(TPanel)使用实例
delphi组件的分类
delphi类的封装
asp.net2.0网站基础之服务器安装IIS
不妨来做个尝试:UpdatePanel,for,ASP.NET,MVC_[Asp.Net教程]
当ASP.NET撞上JSF之应用程序安全性_[Asp.Net教程]
SQL,Server自带的用户自定义函数_mssql学习_编程技术
Javascript与asp.net,实现Ajax多文件无刷新上传_[Asp.Net教程]
PHP购物车类_[PHP教程]
Reading number is top 10 pictures
狗狗与主人神同步2
The world's top ten most beautiful railway station2
Chinese paper-cut grilles art appreciation2
俄罗斯台球天后惊艳魅惑1
Exquisite decoration is not paying too much3
开始让人感动,后来......
Street street fighting
In the world the most mysterious 21 place landscape1
2012 national geographic daily picture7
青春清纯美女大集合4
Download software ranking
仙剑奇侠传98版歌曲
Red cliff
Tram sex maniac 2 (H) rar bag3
美女写真1
I for your crazy
XML+Web+Service开发教程
虚拟机5.5.3版
星际争霸1.08硬盘免安装版
I'm come from Beijing2
Tram sex maniac 2 (H) rar bag13
delv published in(发表于) 2014/1/6 8:48:40 Edit(编辑)
ASP.NET,2005,Treeview终极解决方案_[Asp.Net教程]

ASP.NET,2005,Treeview终极解决方案_[Asp.Net教程]

ASP.NET 2005 Treeview终极解决方案_[Asp.Net教程]

这几天在写HRM的时候 这问题搞了我两天,开始在使用Google 找了半天都是一堆垃圾,都是使用算法的较多, 后来就去了的msdn.yesky.com 找到点启示。 好了废话多说无用。

  首先表结构如下 表名 Test




  写个存储过程 GetTreeview

  这个不用我说了吧下面用到

  为了速度缓存DataTable


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


  至于速度我没测试,如果大家有兴趣帮忙测测。


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.