Dynamically Populate a CheckBoxList in VB.Net
-2
Dynamically Populate a CheckBoxList in VB.Net
'The function to bind the database data to your CheckBoxList Control
Protected Sub bindYourList()
Dim objConn As SqlConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("SqlServer"))
Dim objCmd As SqlCommand = New SqlCommand("select description, id from notificationLists", objConn)
objConn.Open
cblList.DataSource = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
cblList.DataBind
End Sub
'In the Page_Load function call your bind method.
bindYourList()
//in your aspx page make sure to declare your CheckBoxList and define the DataTextField and DataValueField parameters.
<asp:checkboxlist id="cblList" runat="server" DataTextField="description" DataValueField="id">






Databind CheckBoxList Contro?