Nested use of DataList

xiaoxiao2021-03-06  77

Author: China Forum Network collection Source: http: //www.51one.net Add Time: 2004-8-25 datalist is "display item in the data source by using a template" server controls, if the nest for display hierarchy Data is a good choice, (hierarchical data seems to have many provinces in China, there are many counties in the province, there are many townships in the county), which describes how to implement this function. (Also suitable for nested DataGrid & Repeater first look at the following example, Channels is here "channel", there are many columns "columns" under Channels "to display, as if Sina.com's" Life Channel "has a lot of columns, about men Woman, etc..

The program first creates a DataList (id = DATALIST1) to display all Channels, then determine in DataList1's OnItemCreated event When each Item or AlternatingItem is created, we use the program to dynamically generate a DataList to display the columns under this Channel, in When Dynamically generates DataList, the creation of "Display Template" is important, where we use the itemplate interface, custom MyTemp display template, its role is to display the binding data. <% @ Page language = "c #"%> <% @ Import namespace = "system.data"%>