microsoft webcontrols控制項包括四個組件:MultiPage、TabStrip、Toolbar、treeView,treeview可以到http://msdn.microsoft.com/downloads/samples/internet/ASP_DOT_NET_ServerControls/WebControls/default.asp去下載,下載後得到檔案IEWebControls,只有360KB,安裝後自動在C:\Program Files建立IE Web Controls,執行其下面的bulid.bat,如果安裝後還不能使用可以採用以下方法解決:
3、將C:\Program Files\IE Web Controls\build下runtime檔案夾下所有內容複寫到主目錄\webctrl_client\1_0下,是將iewebcontrols四大控制項的系統檔案複製到預設web網站下。
4、將C:\Program Files\IE Web Controls\build下Microsoft.Web.UI.WebControls.dll檔案複製到主目錄中建立的專案檔夾下\bin中。
通過對以上四個方面的操作,iewebcontrols才能正常使用。
二、添加控制項
開啟Microsoft Visual Studio .NET, 在web工具箱中單擊右鍵,選擇自訂工具箱à.NET架構組件,通過瀏覽添加Microsoft.Web.UI.WebControls.dll檔案,添加後可以在.NET架構組件中選擇命名空間為microsoft.web.ui.webcontrols的treeview。
Imports System.Data
Imports System.Data.SqlClient
Public Class tree1
Inherits System.Web.UI.Page
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strconnection As String = "server=zln\netsdk;uid=sa;pwd=sa;database=english"
Dim conn As New SqlConnection(strconnection)
conn.Open()
Dim sql As String = "select * from zlk where kemu='" & Session("node").ToString & "'"
Dim cmd As New SqlCommand(sql, conn)
Dim da As SqlDataReader
da = cmd.ExecuteReader
DataGrid1.DataSource = da
DataGrid1.DataBind()
End Sub
Private Sub TreeView1_SelectedIndexChange(ByVal sender As Object, ByVal e As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs) Handles TreeView1.SelectedIndexChange
Dim ndsel As New Microsoft.Web.UI.WebControls.TreeNode()
ndsel = TreeView1.GetNodeFromIndex(TreeView1.SelectedNodeIndex)
Session("node") = ndsel.Text
End Sub
End Class