Topic: Checklistbox - Binding from SQL Database
Share/Save/Bookmark
1. Add a CheckListBox to your ASP.Net page
2. In the Page_Load method, add the following code:       
 
 
       if (!IsPostBack)
        {
            CC.Object.TopicAreaCollection taColl;
            CC.Business.TopicArea taBLL = new CC.Business.TopicArea();
            taColl = taBLL.GetAll(false);
            chklstTopicArea.DataSource = taColl;
            chklstTopicArea.DataMember = "Description";
            chklstTopicArea.DataTextField = "Description";
            chklstTopicArea.DataValueField = "TopicAreaID";
            chklstTopicArea.DataBind();
            ckklstTopicArea.Items.Insert(0, New ListItem("-- Select Topic Area --",0))
        }
 
3. To check the boxes, use the following:
     
      CheckBoxList1.Items(0).Selected = True
 
      OR
 
      CheckListBox1.Items.FindByValue(Text)