This tutorial will show you how to display data using the .NET CheckBoxList Control, ASP.NET 2.0 and C#.NET

The .NET Framework offers a number of classes that makes populating controls with data easy.

We will need to first import the System.Data.SqlClient namespace. The System.Data.SqlClient namespace contains the methods we will need to query our SQL database.

We’ll put our code in the btnSubmit_Click() event.

When the btnSubmit_Click() event fires it queries our database and creates a new SqlDataReader by invoking the ExecuteReader() method of our cmd object. We make sure to specify the DataTextField property so the CheckBoxList control will know which columns to display as a list.

The front end .aspx page looks something like this:

The flow for the code behind page is as follows.

Download Source Files