DropDownList的树形结构的详细介绍
DropDownList的树形结构的详细介绍
Sub bind_DDL()Dim dtb As DataTable = New DataTable("test")
Dim myDataColumn As New DataColumn
Dim drow As DataRow
Dim i As Int32
myDataColumn.DataType = System.Type.GetType("System.String")
myDataColumn.ColumnName = "c1"
dtb.Columns.Add(myDataColumn)
drow = dtb.NewRow()
drow("c1") = "ItemA"
dtb.Rows.Add(drow)
For i = 0 To 2
drow = dtb.NewRow()
drow("c1") = Server.HtmlDecode(" ") + "ItemA" + i.ToString()
dtb.Rows.Add(drow)
Next
drow = dtb.NewRow()
drow("c1") = "ItemB"
dtb.Rows.Add(drow)
For i = 0 To 2
drow = dtb.NewRow()
drow("c1") = Server.HtmlDecode(" ") + "ItemB" + i.ToString()
dtb.Rows.Add(drow)
Next
DropDownList1.DataSource = dtb
DropDownList1.DataTextField = "c1"
DropDownList1.DataValueField = "c1"
DropDownList1.DataBind()
End Sub