如何使用DropDownList绑定DataTable?
如何使用DropDownList绑定DataTable?
DimqxAsString()
qx=Split("白色,兰色,黄色,黑色,红色",",")
DimdtAsDataTable=NewDataTable("col")
DimdcAsDataColumn=NewDataColumn("str")
dt.Columns.Add(dc)
DimnAsInteger
Forn=0Toqx.Length-1
DimdrAsDataRow=dt.NewRow
dr(0)=qx(n)
dt.Rows.Add(dr)
Next
DropDownList1.DataTextField="str"
DropDownList1.DataValueField="str"
DropDownList1.DataSource=dt
DropDownList1.DataBind()
qx=Split("白色,兰色,黄色,黑色,红色",",")
DimdtAsDataTable=NewDataTable("col")
DimdcAsDataColumn=NewDataColumn("str")
dt.Columns.Add(dc)
DimnAsInteger
Forn=0Toqx.Length-1
DimdrAsDataRow=dt.NewRow
dr(0)=qx(n)
dt.Rows.Add(dr)
Next
DropDownList1.DataTextField="str"
DropDownList1.DataValueField="str"
DropDownList1.DataSource=dt
DropDownList1.DataBind()