TreeView study notes

zhaozj2021-02-12  155

1. What is TreeView?

TreeView is an ASP.NET server control that can generate a user interface for displaying hierarchical data.

2. Applicable data structure:

Applicable stratified data sets, folder views, and other similar data structures.

3. How to implement TreeView?

(1) Create a declaration

(2) The client or server is programmed in a variety of ways

4. TreeView creation method:

(1) Manual creation

(2) Create TreeView Editor in VS.NET

5. TreeView elements

TreeView defines a treeview

TREENODETYPE Defines a node type to apply one or a set of nodes in TreeView

Treenode creates a node in TreeView

Note:

TreeView is container for Treenode and Treenodetype

These elements jointly define the structure, layout, and outside of the number view.

View. TreeView cannot contain anything other than these three elements

HTML element

6. Write simple TreeView

(1). Create a web application, named: WebControls

(2). Create an empty page

(3). Add a namespace reference, add "<% @ Import namespace =" Microsoft.Web.ui.WebControls "%>"

(4) Add @ register instruction

Add:

<% @ Register tagprefix = "mytree"

Namespace = "Microsoft.Web.ui.WebControls"

AskMBLY = "Microsoft.Web.ui.WebControls, Version = 1.0.2.226, Culture = neutral, publickeyToken = 31BF3856AD364E35"%>

(5). Add a document structure

(6). Add FORM

All webcontrol elements must be established in an FORM element

(7). Add a TreeView element.

(8) Add a TREENODE to TreeView.

(9). Add a second TREENODE.

7. Data binding

TreeView also supports data binding, thus generating dynamic content, the following example displayed TreeView is similar to the previous example, but does not use static content, but use the Scalable Markup Language (XML) file to provide the UI data source

Expanded = "true" Treenodesrc = "http:// Eventargs / WebControls / TreeView / Book.xml">

Book.xml file contains the following:

8. Data binding with XML and SQL Server

WebControls elements can also use other XML data providers as follows:

Treenodesrc = "http:// Eventargs / mysqlxml? SQL = Execute sp_bookxml @ pid = 1" />

This example uses a more advanced technology. The Treenodesrc property is set to a URL, the latter performs a stored procedure on the Microsoft SQL Server (TM) database to dynamically generate XML data island.

9. Program

The example given in the previous shows that in most cases, writing a functional UI element does not require any programming. This section briefly introduces some simple scripting techniques available for TreeView.

TreeView event

The event-oriented server that interacts can be generated by setting the AutoPostBack property to TRUE. Server-side scripts should be used when handling advanced browsers and low browser events, because there is no rich DHTML behavior in Internet Explorer 5.5 or later in low-level page content.

For web pages containing TreeView, the user's main interaction is the node in which it is expanded and folded to browse content. The following sample code shows how to use C # to handle OnexPand, ONCOLLLAPSE, and OnsectedIndexchange events in a web form.