文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ASP.NET 2005 Treeview终极解决方案_Asp.Net开发技巧

ASP.NET 2005 Treeview终极解决方案_Asp.Net开发技巧

时间:2010-09-16  来源:蔚蓝的大海

 这几天在写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

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

get free internet sprintmax length vga cableoutdoor movie projector rentaldynex card reader drivers for macrack mount computertransfer music lg dareapple rogers high speedstaples computermetro wire shelvingfirewire usb cablesony rs422 pinoutjapanese o ring sizeswii console radio shackkenny rogers official websiteusb 2.0 vistaroadrunner outgoing servertypes xd memory cardsnikon d200 circuit citylinksys lne100tx fast ethernet adapter driveri860 data cablehdmi specification 1.3pcmcia wireless external antennavista compatible sound cardsduplicate sim card forumpontiac power window repairatmel flash memorylist computers networkparallel vs series speaker wiringcoaxial cablelaptop stereo connectionlevel one wireless adapters video monitor cabledownload older nvidia driversi2c interfacescart leadapple wireless adaptordvi connection computermcmaster wikisony wega hdtv 32cute pdfvideo pro sim limpirating cableinternet download gameswifi antenna connectorsata drivespsql import sql filecity link depotsuppliers automotive industrywii repair tipsdazzle capture card driver

Replica lv Hangbags

Replica Hangbags

Hangbags

replica handbags

replica handbags

replica handbags

replica handbags

handbags

replica handbags replica handbags replica handbags replica handbags replica handbags

usb cable

usb cable

usb cable

usb cable

usb flash drives

usb flash drives

usb flash drives usb flash drives usb flash drives usb flash drives USB Connector USB Connector USB Connector USB Connector USB Connector USB Connector
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载