高分求vb的treeview实例
高分求vb的treeview实例,要求绑定数据库的.最好是SQL,顺便问两个小问题:
1,创建存储过程之后怎么调用,有简单代码是好(新手)
2,怎么删除上传的文件,比如在upload\word.doc文件,file.delete好像不行!
问题多了.分不够再加!
------解决方案--------------------http://www.pcdog.com/p/html/200515/5120057154_1.htm
------解决方案--------------------没有人回你,主要是你太懒,想吃现成的。 谁有功夫给你整一个完成的代码?一般只提供你思路,或者代码片断。 你得自己去编。
------解决方案--------------------
------解决方案--------------------up
------解决方案--------------------没有现成的实例
普通用法,加这一句:
com.CommandType = CommandType.StoredProcedure
delete:是不是取得的路径有问题
------解决方案--------------------为了速度缓存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