asp.net|treeview| control China It power, the latest and most complete it technology Tutorials Latest 100 | Recommended 100 Articles | Topic 100 Articles | List |
Search| Online API Document Home | Program Development | Operating System | Software Application | Graphic image | Network Applications | Refined Literature | Education Certification | Unfinished articles | Technical discussion ASP JS PHP engineering asp.net website Construction UML J2eesun. NET
VCVBVFPNetwork Maintenance Database DB2 SQL2000 Oracle Mysql server Win2000 Office
CDreamWeaver FireWorks Flash PhotoShop
Access to the BibleCorelDraw Protocol Daquan Network Security Microsoft certification Current Location: > Program Development > Web Development >. NET > asp.net
ASP. NET in the TreeView Control usage SummaryAuthor: unknown time: 2004-09-07 12:12 Source: ahcit Zebian: Chinaitpower Summary: No online browsing sometimes will see some sites on the left with similar resource Manager tree structure, click in the tree structure, display content on the right, level Clear and convenient, this article mainly introduces the use of ASP.net server control TreeView, the TreeView control belongs to the Microsoft WebControls, in the download and use of the process I encountered some problems, through repeated experiments to find information, Find some solutions and write out the TreeView usage to help friends who want to use the tree structure on their site.
First, download
The Microsoft WebControls control includes four components: MultiPage, TabStrip, Toolbar, Treeview,treeview can go to http://msdn.microsoft.com/ downloads/samples/internet/asp_dot_net_servercontrols/webcontrols/ default.asp to download, download after the file iewebcontrols, only 360KB, after installation automatically in C:\Program files to establish IE Web Controls, To perform the following bulid.bat, if it is not available after installation, you can resolve it using the following methods:
1, Open the contents of the Bulid.bat to see if the csc.exe path is correct, generally not correct use this may be one of the reasons, csc.exe for system files, if it's path does not conform to your computer, modify the save to execute Bulid.bat, will get Microsoft.Web.UI.WebCon Trols.dll and some folders.
2, view the default Web site, the general Default Web site for C:\Inetpub\wwwroot, if not you can open the Administrative Tools Àinternet Service Manager, methods: The Default Web site click the right à properties à home directory, modify the home directory.
3, the C:\Program files\ie Web controls\build under the Runtime folder to copy all contents under the main directory \WEBCTRL_CLIENT\1_0, is to copy the system files of the four Iewebcontrols controls to the default Web site.
4, copy the C:\Program files\ie Web controls\build Microsoft.Web.UI.WebControls.dll file to the project folder set up in the home directory under \ Bin.
Through the above four aspects of operation, iewebcontrols to normal use.
second, add controls
Open Microsoft Visual Studio. NET, right-click in the Web Toolbox, and select Custom Toolbox à. NET Framework component, you can select the TreeView in the. NET Framework component as microsoft.web.ui.webcontrols by browsing the Add Microsoft.Web.UI.WebControls.dll file.
Introduction to the TreeView properties and Methods
Add a TreeView control to the form to create the desired tree structure from the TreeView object's properties nodes.
Example: Establish the following tree-shaped structure
The HTML code in the form is:
<iewc:treeview id= "treeview1" Autoselect=false shoplus=true showlines=true expandlevel=2 runat=server>
<iewc:treenode text= "Subjects" >
<iewc:treenode text= "Language"/>
<iewc:treenode text= "Mathematics"/>
<iewc:treenode text= "English"/>
</iewc:treenode>
</iewc:treeview>
1, autoselect= "false": When a visitor locates a node in the TreeView control, you can use the arrows on the keyboard to navigate. Property value is ' false ', this is not allowed.
2, showplus= "true": when two nodes received together, you can display a plus (+), the visitor knows that the node can be expanded, the property value of "True" will use the plus sign, otherwise not used.
3. Showlines= "true": between two nodes in a TreeView control, you can display some line lengths, which are displayed as "true".
4, expandlevel=2: The number of levels used to define the hierarchy expansion of the TreeView control.
5, NavigateUrl: Click on the node when the jump URL
Such as:
<iewc:treeview id= "TreeView2" runat=server>
<iewc:treenode text= "Favorite Sites" >
<iewc:treenode text= "China dotnet Club" navigateurl= "http://www.chinaaspx..com"
<iewc:treenode text= "National basic Education Resource Network" navigateurl= "htt://www.cbern.gov.cn"
</iewc:treenode>
</iewc:treeview>
6. Index: Gets the location of the tree node in the tree node collection
7, nodes: Get the tree node collection assigned to the tree view control
8. Parent: Gets or sets the parent container for the control
9. SelectedNode: Gets or sets the tree node currently selected in the tree view control
10. Text: Gets or sets the text displayed in the tree node label
11, expand: Expand the tree node
12. Clear: Empty the tree
13, remove: Remove the current tree node
14, checked: to indicate whether the tree node is selected
Four, simple example
Make a selection of the left tree structure, and the query displays the results in the table on the right.
Description
1, Selectedindexchange event is to choose the tree structure, there is also a trigger condition autopostback=true.
2. In the example, the database is established by SQL 2000.
The code is as follows:
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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.