[原创]DropDownList的树形结构

 1Sub bind_DDL()
 2        Dim dtb As DataTable = New DataTable("test")
 3        Dim myDataColumn As New DataColumn
 4        Dim drow As DataRow
 5        Dim i As Int32
 6        myDataColumn.DataType = System.Type.GetType("System.String")
 7        myDataColumn.ColumnName = "c1"
 8        dtb.Columns.Add(myDataColumn)
 9        drow = dtb.NewRow()
10        drow("c1"= "ItemA"
11        dtb.Rows.Add(drow)
12        For i = 0 To 2
13            drow = dtb.NewRow()
14            drow("c1"= Server.HtmlDecode("  "+ "ItemA" + i.ToString()
15            dtb.Rows.Add(drow)
16        Next
17        drow = dtb.NewRow()
18        drow("c1"= "ItemB"
19        dtb.Rows.Add(drow)
20        For i = 0 To 2
21            drow = dtb.NewRow()
22            drow("c1"= Server.HtmlDecode("  "+ "ItemB" + i.ToString()
23            dtb.Rows.Add(drow)
24        Next
25        DropDownList1.DataSource = dtb
26        DropDownList1.DataTextField = "c1"
27        DropDownList1.DataValueField = "c1"
28        DropDownList1.DataBind()
29    End Sub
 
posted @ 2005-07-08 12:33  PointNet  阅读(639)  评论(1编辑  收藏  举报