我的数据库是这样的:
我在datalist里有一个RadioButtonList控件...我想要它绑定数据库里的选项...............
我后台代码这样的:
Private Sub datalist1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles datalist1.ItemDataBound
Dim rbl As RadioButtonList = DirectCast(e.Item.FindControl("RadioButtonList1"), RadioButtonList)
Dim conn As OleDbConnection
Dim conStr As String
Dim rs As OleDbDataReader
conStr = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("data\data.mdb")
conn = New OleDbConnection(conStr)
Dim comm As OleDbCommand
Dim comStr As String
comStr = "select * from 题目表"
comm = New OleDbCommand(comStr, conn)
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
da.SelectCommand = comm
conn.Open()
da.Fill(ds, "题目表")
rbl.DataSource = ds
rbl.DataTextField = "选项1"
rbl.DataBind()
End Sub