读出DataSetdropdownlist1.DataSource = ds.Tables[0].DefaultView;
dropdownlist1.DataTextFiled = "Area";
dropdownlist1.DataValueFiled = "Area";
dropdownlist1.DataBind();
dropdownlist1.DataTextFiled = "Area";
dropdownlist1.DataValueFiled = "Area";
dropdownlist1.DataBind();
MyDropDownList.DataTextField="Area";
MyDropDownList.DataValueField="Area";
MyDropDownList.DataBind();
DropDownList1.DataSource=ds.Tables[0].DefaultView;;
DropDownList1.DataTextField="Textxxx";
DropDownList1.DataValueField="valuexxx";
DropDownList1.DataBind();
Dim DT As DataTable
Dim DR As DataRow
DT = New DataTable("DT")
DT.Columns.Add("key", GetType(String))
DT.Columns.Add("value", GetType(String)) DR = DT.NewRow
Dim strSQL As String = “your sql string ”
conn.Open()
Dim sqlDBcmd As SqlCommand = New SqlCommand
sqlDBcmd.Connection = conn
sqlDBcmd.CommandText = strSQL
Dim DBreader As SqlDataReader = sqlDBcmd.ExecuteReader()
While DBreader.Read()
DR(0) = DBreader.Item(0)
DR(1) = DBreader.Item(1)
DT.Rows.Add(DR)
DR = DT.NewRow
End While
DBreader.Close()MyDropDownList.DataSource=DT
'to dongchuanlu(匡奇),这里无需.defaultview
MyDropDownList.DataTextField="key";
MyDropDownList.DataValueField="value";
MyDropDownList.DataBind();
然后
DropDownList1.DataSource=ds.Tables[0].DefaultView;;
DropDownList1.DataBind();
就可以了
VoteItemStr = "SELECT * FROM play_voteItem"
VoteItemCmd = New SqlDataAdapter(VoteItemStr,MyConnection8)
DS8 = New DataSet()
VoteItemCmd.Fill(DS8,"items")
VoteItemDataList.DataSource = DS8.Tables("items").DefaultView
VoteItemDataList.DataBind()
MyConnection8.Close()