TAILIEUCHUNG - ASP.NET 4 Unleased - p 110

Các trang trong Ví dụ 22,26 bộ lọc các nội dung của bảng cơ sở dữ liệu Thảo luận theo cột ParentID của nó. Thứ nhất, các nút cấp cao được thêm vào TreeView. Tiếp theo, các nút con là đệ quy thêm vào TreeView với sự giúp đỡ của các AddChildTreeViewNodes () phương pháp. | 1064 CHAPTER 22 Using the Navigation Controls DataView view new DataView treeViewData ParentID foreach DataRowView row in view TreeNode newNode new TreeNode row Subject .ToString row MessageId .ToString newNode AddChildTreeViewNodes treeViewData newNode script html xmlns http 1999 xhtml head id Head1 runat server style type text css style title TreeView Database title head body form id form1 runat server div asp TreeView id TreeView1 Runat server div form body html The page in Listing filters the contents of the Discuss database table by its ParentID column. First the top-level nodes are added to the TreeView. Next the child nodes are recursively added to the TreeView with the help of the AddChildTreeViewNodes method. Using Populate On Demand and AJAX You can use the TreeView control even when working with a large set of data. For example the Microsoft MSDN website has links to thousands of articles. This website uses a tree view to display the nested links to the articles. Because thousands of articles are hosted at the MSDN website not all the tree nodes are downloaded to the browser when you open a page. Instead additional nodes are downloaded to your browser only when you expand a particular node. From the Library of Wow eBook Using the TreeView Control 1065 You can use a feature named Populate On Demand with the TreeView control. When you enable the PopulateOnDemand property for a Tree node child nodes are not added to the parent node until the parent node is expanded. For example the page in Listing contains an infinitely expanding TreeView. Each time you expand a Tree node five new child nodes display. Each time you expand a child node five more child nodes display and so on see Figure . 22 FIGURE An infinitely expanding TreeView control. LISTING @ Page Language C DOCTYPE html PUBLIC - W3C DTD .