In this article we will learn how to Bind Chekbox List and get the Selected Items from List. We will make a Web application using C#. Let’s start.
- Open Visual Studio. Select New Web Site.

- Name it as you want. My application's name is CheckBoxList_Example.

- First Of All Add Web Form. Go to Solution Explorer > Right Click on the Web Site > Select Add > Add New Item > Select > Web Form and Give the Web Form Name, My We Form Page Name Is CheckList_Page.

- Add Check Box List , Label and Button On CheckList_Page.aspx Page.
- <asp:CheckBoxList ID="CheckboxList1" runat="server" AutoPostBack="false" Width="450px">
- </asp:CheckBoxList>
- <asp:Label ID="lblmsg" class="textcls" runat="server"></asp:Label>
- <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Show Data" />
- Create a method for Bind the CheckBox List.
- protected void Bind_CheckList() // Method for Binding The Checkbox List
- {
- List<string> listContents = new List<string>();// Create a List of String Elements
- listContents.Add("DehraDun");
- listContents.Add("Shimla");
- listContents.Add("Patna");
- listContents.Add("Mumbai");
- listContents.Add("Delhi");
- listContents.Add("Goa");
- listContents.Add("Chennai");
- listContents.Add("Noida");
- listContents.Add("GuruGram");
- CheckboxList1.DataSource = listContents;//Set Datasource to CheckBox List
- CheckboxList1.DataBind(); // Bind the checkboxList with String List.
- }
- Call this Method On PageLoad.
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Page.IsPostBack == false)
- {
- Bind_CheckList();// Call CheckBox List Bind Method.
- }
- }
- Get the selected Item List From CheckBoxList Items and show Selected Items List with Help of Label .
- protected void Button1_Click(object sender, EventArgs e)
- {
- string str = "";
- for(int i=0;i<CheckboxList1.Items.Count ;i++)
- {
- if(CheckboxList1.Items[i].Selected==true)// getting selected value from CheckBox List
- {
- str += CheckboxList1.Items[i].Text + " ," + "<br/>" ; // add selected Item text to the String .
- }
- }
- if(str!="")
- {
- str = str.Substring(0, str.Length - 7); // Remove Last "," from the string .
- lblmsg.Text = "Selected Cities are <br/><br/>" + str; // Show selected Item List by Label.
- }
- }
I hope this is helpful for developing. Thanks.

Vikram SinghPosted May 16, 2020, 3:59 AM
How to select one check box in multiple check box
akshay raikarPosted Oct 30, 2018, 12:20 AM
How to fetch local API in asp.net
Hitesh LadePosted May 9, 2018, 3:56 AM
It helped me.Now My only problem left is to store each selected listbox in different row of same table.
Ravinder KumarPosted Sep 27, 2016, 6:46 AM
Nice One
Ravinder KumarPosted Sep 27, 2016, 6:45 AM
Very usefull