Popolare una CheckBoxList leggendo i dati da Access
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<HTML>
<script language="VB" runat="server">
Dim MyConnection As OleDbConnection
Public Sub Page_Load(ByVal Sender As System.Object, ByVal E As System.EventArgs) Handles MyBase.Load
MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source=" & _
Server.MapPath("database/utenti.mdb"))
If Not (IsPostBack) Then
BindRadio()
End If
End Sub
Sub BindRadio()
Dim DS As DataSet
Dim MyCommand As OleDbDataAdapter
MyCommand = New OleDbDataAdapter("select * from utenti", MyConnection)
DS = New DataSet
MyCommand.Fill(DS, "utenti")
Dim Source As DataView = DS.Tables("utenti").DefaultView
cblEmails.DataSource = Source
cblEmails.DataBind()
End Sub
</script>
<body>
<form runat="server" ID="Form1">
<asp:CheckBoxList id="cblEmails" runat="server"
DataValueField="email" DataTextField="email" />
</form>
</body>
</html>