Category Archives: CheckBoxList Control Example

How to Remove Selected Item from CheckBoxList in ASP.Net

In this ASP.Net tutorials we are to learn how to Remove Selected Item from CheckBoxList control Programmatically in ASP.Net with C# Language.

STEP 1 – Design the ASP.Net webpage with one CheckBoxList Control, One Button Control and One Label Control:

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>&nbsp;Remove
Selected Item – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”Remove Selected” Font-Bold=”True” Font-Size=”Medium” />&nbsp;</td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” Width=”168px”>
<asp:ListItem Value=”1″>ABC</asp:ListItem>
<asp:ListItem Value=”2″>DEF</asp:ListItem>
<asp:ListItem Value=”3″>GHI</asp:ListItem>
<asp:ListItem Value=”4″>PQR</asp:ListItem>
<asp:ListItem Value=”5″>STU</asp:ListItem>
<asp:ListItem Value=”6″>XYZ</asp:ListItem>
</asp:CheckBoxList>
<asp:Label ID=”Label1″ runat=”server”></asp:Label></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

– The ASP.Net CheckBoxList Control Remove Item Example output is:

 Remove selected item from CheckBoxList control in ASP.Net with C#

Remove selected item from CheckBoxList control in ASP.Net with C#

STEP 2 – Now select the item from CheckBoxList Contol.

Remove selected item from CheckBoxList control in ASP.Net with C#

Remove selected item from CheckBoxList control in ASP.Net with C#

STEP 3 – Write the Below code on Button Click Event at Code behind page of ASP.Net for Removing Selected Item:

protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected == true)
{
CheckBoxList1.Items.RemoveAt(i);
Label1.Text = “Item Removed”;
}
}
}

–  The ASP.Net Remove Selected Item From CheckBoxlist Control Exmaple output is:

Remove selected item from CheckBoxList control in ASP.Net with C#

Remove selected item from CheckBoxList control in ASP.Net with C#

I hope you enjoy this ASP.Net Exmaple of Remove selected item from CheckBoxList Control.

How to use CssClass Style on CheckBoxList in ASP.Net

In  this ASP.Net post we will learn how to apply style with CssClass programmatically on CheckBoxList Control in ASP.Net

– There are many way to apply style on web control.

STEP 1 – Design the ASP.Net webpage for CssClass Example:

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>Apply CssClass
on CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”View CheckBoxList” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
&nbsp;<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” Width=”168px”>
</asp:CheckBoxList></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

– ASP.Net Example of CssClass CheckBoxList Control output is:

Use CssClass on CheckBoxList Control programmatically in ASP.Net

Use CssClass on CheckBoxList Control programmatically in ASP.Net

STEP 2 – Create the CssClass in Head Section of webform HTML code:

<head runat=”server”>
<title>CheckBoxList CssClass in ASP.Net</title>
<style type=”text/css”>
.CListStyle
{
font-family:Courier New;
font-weight:bold;
color:Red;
font-size:Xlarge;
}
</style>
</head>

 

STEP 3 – Write below code on Button Click Event at code behind page of ASP.Net:

 protected void Page_Load(object sender, EventArgs e)
{
string[] Days = { “Sunday”, “Monday”, “Tusday”, “Wednesday”, “Thursday” };
CheckBoxList1.DataSource = Days;
CheckBoxList1.DataBind();
}

protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList1.CssClass = “CListStyle”;
}

 

– The ASP.Net CheckBoxList CssClass Example output is:

Use CssClass on CheckBoxList Control programmatically in ASP.Net

Use CssClass on CheckBoxList Control programmatically in ASP.Net

– Here on above Example we learn apply CssClass programmatically, The Same thing wil can do without progammatically in ASP.Net.

– Just go to the  CheckBoxList control Property tab and write the Class name on CssClass property.

– Hope this asp.net example of use CssClass on CheckBoxList control will help you……

How to Count Selected Item of CheckBoxList in ASP.Net

Hi all, here in this asp.net tutorials we will learn to count how many item selected on checkboxlist control in ASP.Net.

– We all are aware of CheckBoxList control in ASP.Net. So, we all know how to select item on CheckBoxList Control, Here we just learn to count that Select Item of CheckBoxList control in ASP.Net with an Example.

STEP 1 – First Design the ASP.Net webpage with one CheckBoxList Control, one Button Control and one Label Control for dispaly the result of Example.

– The HTML Design code for ASP.Net Example is:

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>Count Selected
Item – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”Count Selected” Font-Bold=”True” Font-Size=”Medium” />&nbsp;</td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” Width=”168px”>
</asp:CheckBoxList>
<asp:Label ID=”Label1″ runat=”server”></asp:Label></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>

 

– The ASP.Net Example of CheckBoxList Selected Item Count design output is:

Count Selected items of CheckBoxList Control in ASP.Net with C#

Count Selected items of CheckBoxList Control in ASP.Net with C#

STEP 2 – Write the below code at code behing page of ASP.Net webform.

protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{

string[] Days = { “Sunday”, “Monday”, “Tusday”, “Wednesday”, “Thursday” };
CheckBoxList1.DataSource = Days;
CheckBoxList1.DataBind();
}
}

protected void Button1_Click(object sender, EventArgs e)
{
int count=0;
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected == true)
{
count=count+ 1;
}
}
Label1.Text =”Selectd Item = “+ count.ToString();
}

 

– The ASP.Net Example of CheckBoxList Selected Item Count output is:

Count Selected items of CheckBoxList Control in ASP.Net with C#

Count Selected items of CheckBoxList Control in ASP.Net with C#

– The above asp.net result display the Three items selected on checkboxlist control in asp.net.

– This ASP.Net Example of CheckBoxList Control Selected Item Count will help you……

How to use CellSpacing and CellPadding in CheckBoxList Control

Here, In this ASP.Net tutorials we are going to learn how to use CellSpacing and CellPadding on CheckBoxList Control in ASP.NET with C#.

STEP 1 – Design the ASP.Net web page with One CheckBoxList Control with Two Button Control :

<table style=”width: 464px”>
<tr>
<td colspan=”2″ style=”height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>&nbsp;CellPadding
and CellSpacing – CheckBoxList</span></strong></td>
</tr>
<tr>
<td colspan=”2″ style=”height: 24px; text-align: center”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”CellPadding ” Font-Bold=”True” Font-Size=”Medium” />
<asp:Button ID=”Button2″ runat=”server” OnClick=”Button2_Click” Text=”CellSpacing” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”text-align: center”>
</td>
<td style=”text-align: left;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” BorderColor=”#8080FF” BorderStyle=”Solid” BorderWidth=”3px” Font-Bold=”True” ForeColor=”Blue”>
<asp:ListItem Value=”1″>ABC</asp:ListItem>
<asp:ListItem Value=”2″>DEF</asp:ListItem>
<asp:ListItem Value=”3″>GHI</asp:ListItem>
<asp:ListItem Value=”4″>PQR</asp:ListItem>
<asp:ListItem Value=”5″>STU</asp:ListItem>
<asp:ListItem Value=”6″>XYZ</asp:ListItem>
</asp:CheckBoxList>&nbsp;
</td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

– The ASP.Net Example of CheckBoxList CellSpacing and CellPadding output is:

CheckBoxList Control CellPAdding in ASP.Net with C#

CheckBoxList Control CellPAdding in ASP.Net with C#

STEP 2 – Write the below code on code behind page of ASP.Net webform for CellSpacing and CellPadding.

protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList1.CellPadding = 7;
}
protected void Button2_Click(object sender, EventArgs e)
{
CheckBoxList1.CellSpacing = 7;
}

 

– The ASP.Net Example of CheckBoxList CellSpacing output is:

CheckBoxList Control CellSpacing in ASP.Net with C#

CheckBoxList Control CellSpacing in ASP.Net with C#

– The ASP.Net Example of CheckBoxList control CellPadding output is:

CheckBoxList Control CellPAdding in ASP.Net with C#

CheckBoxList Control CellPAdding in ASP.Net with C#

– Hope this ASp.Net Example of CheckBoxList control CellPadding and CellSpacing will help you…….

How to use Theme and SkinID on CheckBoxList in ASP.Net

Here, In this ASP.Net tutorials we are going to learn how to use theme and skinID on CheckBoxList Control in ASP.NET with C#.

STEP 1 – Design the ASP.Net web page with Two CheckBoxList Control :

<table style=”width: 464px”>
<tr>
<td colspan=”2″ style=”height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>&nbsp;Apply
Theme and SkinID – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList  SkinID=”Red” ID=”CheckBoxList1″ runat=”server”>
<asp:ListItem Value=”1″>ABC</asp:ListItem>
<asp:ListItem Value=”2″>DEF</asp:ListItem>
<asp:ListItem Value=”3″>GHI</asp:ListItem>
<asp:ListItem Value=”4″>PQR</asp:ListItem>
<asp:ListItem Value=”5″>STU</asp:ListItem>
<asp:ListItem Value=”6″>XYZ</asp:ListItem>
</asp:CheckBoxList></td>
<td style=”width: 257px; height: 22px; text-align: center”>
<asp:CheckBoxList ID=”CheckBoxList2″ SkinID=”Green” runat=”server”>
<asp:ListItem Value=”1″>ABC</asp:ListItem>
<asp:ListItem Value=”2″>DEF</asp:ListItem>
<asp:ListItem Value=”3″>GHI</asp:ListItem>
<asp:ListItem Value=”4″>PQR</asp:ListItem>
<asp:ListItem Value=”5″>STU</asp:ListItem>
<asp:ListItem Value=”6″>XYZ</asp:ListItem>
</asp:CheckBoxList></td>
</tr>
</table>

 

STEP 2 – Create SkinFile in Theme1 Folder and write below code in SkinFile:

Learn How to create SkinFile

<asp:CheckBoxList runat=”server” SkinID=”Red” Width=”168px” BackColor=”Red” Font-Bold=”True”></asp:CheckBoxList>
<asp:CheckBoxList runat=”server” SkinID=”Green” Width=”168px” BackColor=”LightGreen” Font-Italic=”true”></asp:CheckBoxList>

 

STEP 3 – Apply Theme to ASP.Net webpage:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”ClistThemeSkinID.aspx.cs” Inherits=”chkbox_Clistskonid” Theme=”Theme1″ %>

 

The ASP.Net CheckBoxList Theme and SkinID Example output is:

How to use Theme and SkinID in CheckBoxList - ASP.Net C#

How to use Theme and SkinID in CheckBoxList – ASP.Net C#

– I hope this ASP.Net Example of CheckBoxList SkinID will help you………..

How to Apply Theme on CheckBoxList Control in ASP.Net

 

In this ASP.Net tutorials we will learn how to apply them on CheckBoxList Control in ASP.Net with C#.

 

STEP 1 – Design the Web Page with one CheckBoxList Control on ASP.Net Page:

  <table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>&nbsp;Apply
Theme – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server”>
<asp:ListItem Value=”1″>ABC</asp:ListItem>
<asp:ListItem Value=”2″>DEF</asp:ListItem>
<asp:ListItem Value=”3″>GHI</asp:ListItem>
<asp:ListItem Value=”4″>PQR</asp:ListItem>
<asp:ListItem Value=”5″>STU</asp:ListItem>
<asp:ListItem Value=”6″>XYZ</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
</table>

 

STEP 2 – Now, Add Theme Folder on Solution Explore:

Right Click on Project  —> Add ASP.NET Folder  —>  Theme

Aplly Theme on CheckBoxList Control in ASP.NET with C#

Aplly Theme on CheckBoxList Control in ASP.NET with C#

STEP 3 – Add New Skin File in Theme Folder:

Right Click on Theme1 —> Add New Item  —>  Skin File

Add Akin File on Theme Folder in ASP.NET with C#

Add Akin File on Theme Folder in ASP.NET with C#

Now, Create the Theme, write Theme code in SkinFile :

Here, We have created theme for CheckBoxList control like: (write this code in SkinFile)

<asp:CheckBoxList runat=”server” Width=”168px” BackColor=”LightGreen” Font-Italic=”true”></asp:CheckBoxList>

 

STEP 4 – Apply this Theme1 to ASP.Net web page like:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”ClistTheme.aspx.cs” Inherits=”chkbox_Clisttheme” Theme=”Theme1″ %>

 

The ASP.Net CheckBoxList Theme Example output is:

Apply Theme to CheckBocList Control in ASP.Net with C#

Apply Theme to CheckBocList Control in ASP.Net with C#

I hope you will enjoy this ASP.NET CheckBoxList Control Theme Examaple……..

How to use ClearSelection() Method CheckBoxList in ASP.Net C#

In this ASP.Net tutorials we are going to learn How to use ClearSelection() Method CheckBoxList Control Programmatically in ASP.Net with C#.

STEP 1 – Design the ASP.Net web form with One CheckBoxList Control along with the One Button Control:

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>ClearSelection()
Method – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”Clear Selection()” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” Width=”168px”>
</asp:CheckBoxList></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

The ASP.Net CheckboxList Control ClearSelection() Method output is :

The ASP.Net CheckboxList Control ClearSelection() Methos Example with C#

The ASP.Net CheckboxList Control ClearSelection() Methos Example with C#

STEP 2 – write below code on Button click event on ASP.Net code page:

protected void Page_Load(object sender, EventArgs e)
{
string[] Days = { “Sunday”, “Monday”, “Tusday”, “Wednesday”, “Thursday” };
CheckBoxList1.DataSource = Days;
CheckBoxList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList1.ClearSelection();
}

The ASP.Net CheckboxList Control ClearSelection() Method output is :

The ASP.Net CheckboxList Control ClearSelection() Methos Example with C#

The ASP.Net CheckboxList Control ClearSelection() Methos Example with C#

I hope this ASP.Net tutorials CheckboxList Control ClearSelection() Methos Example with C# will help you ….

How to change CheckBoxList Control Text Align in ASP.Net

In this ASP.Net tutorials we are going to learn How to change Text Align (Left / Right) Checkboxlist Control Programmatically in ASP.Net with C#.

STEp 1 – Design the ASP.Net web form with One CheckBoxList control along with Two Button Control :

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>&nbsp;Text
Align Left / Right – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”LEFT Align” Font-Bold=”True” Font-Size=”Medium” /><asp:Button ID=”Button2″ runat=”server” OnClick=”Button2_Click” Text=”RIGHT Align” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” Width=”168px”>
<asp:ListItem Value=”1″>ABC</asp:ListItem>
<asp:ListItem Value=”2″>DEF</asp:ListItem>
<asp:ListItem Value=”3″>GHI</asp:ListItem>
<asp:ListItem Value=”4″>PQR</asp:ListItem>
<asp:ListItem Value=”5″>STU</asp:ListItem>
<asp:ListItem Value=”6″>XYZ</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

The ASP.Net CheckboxList Control Text Align Example output is :

The ASP.Net CheckboxList Control Text Align Example in ASP.Net with C#

The ASP.Net CheckboxList Control Text Align Example in ASP.Net with C#

STEP 2 – write below code on Button Click event of ASP.Net code page:

 protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList1.TextAlign = TextAlign.Left;
}
protected void Button2_Click(object sender, EventArgs e)
{
CheckBoxList1.TextAlign = TextAlign.Right;
}

The ASP.Net CheckboxList Control Text Align Example output is :

The ASP.Net CheckboxList Control Text Align Example in ASP.Net with C#

The ASP.Net CheckboxList Control Text Align Example in ASP.Net with C#

 

I hope this ASP.Net CheckBoxList Contol Text Align Example will help you …..

How to ADD New Item to CheckBoxList Programmatically in ASP.Net

In this ASP.Net Tutorials we will learn, How to ADD New Item in CheckBoxList Programmatically in ASP.Net with C# with an Example.

STEP 1 – Design the ASP.Net web form with a TextBox Control, a Button Control, a CheckBoxList Control and one Label Control look like :

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>&nbsp;ADD
New Item – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”ADD Item” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” Width=”168px”>
</asp:CheckBoxList>
<asp:Label ID=”Label1″ runat=”server”></asp:Label></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

The ASP.Net CheckboxList Control ADD New Item Example output is :

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

STEP 2 – write the below code on Button Click event of ASP.Net code page:

protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList1.Items.Add(TextBox1.Text);
Label1.Text = “Item Added Successfully !”;
}

The ASP.Net CheckboxList Control ADD New Item Example output is :

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

The ASP.Net CheckboxList Control ADD New Item Example output is :

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

Add new item to CheckboxList Control programmaticaly in ASP.Net with C#

I hope this Add new item to CheckboxList Control programmaticaly in ASP.Net with C# tutorial will help you…….

How to use CheckBoxList OnDataBinding event in ASP.Net C#

In this ASP.Net tutorialswe will teach you, How to use CheckBoxList control OnDataBinding event in ASP.Net C#.

STEP 1 – Design the ASP.Net Web form with one CheckBoxList control one Button control and one Label Control:

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>OnDataBinding
Event in CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”View CheckBoxList” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:Label ID=”Label1″ runat=”server”></asp:Label><asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” OnDataBinding=”CheckBoxList1_DataBinding”
OnDataBound=”CheckBoxList1_DataBound” Width=”168px”>
</asp:CheckBoxList></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

The ASP.Net CheckboxList Control OnDataBinding Event Example output is :

ASP.Net CheckboxList Control OnDataBinding Event Example with C#

ASP.Net CheckboxList Control OnDataBinding Event Example with C#

STEP 2 – write below code on Button Click Event and OnDataBinding Event of ASP.Net code page:

   protected void CheckBoxList1_DataBinding(object sender, EventArgs e)
{
Label1.Text = “Week Days”;
Label1.ForeColor = System.Drawing.Color.Red;
Label1.Font.Size = FontUnit.Large;
}

The ASP.Net CheckboxList Control OnDataBinding Event Example output is :

ASP.Net CheckboxList Control OnDataBinding Event Example with C#

ASP.Net CheckboxList Control OnDataBinding Event Example with C#

I hope this ASP.Net tutorials of Checkboxlist control OnDataBinding Event will help you….

How to use CheckBoxList OnDataBound event in ASP.Net C#

In this ASP.Net Tutorials we will learn How to use CheckBoxList OnDataBound event in ASP.Net C#.

STEP 1 – Design the ASP.Net Web form with one CheckBoxList control, one Button control and one Label Control:

 <table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>OnDataBinding
Event in CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”View CheckBoxList” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:Label ID=”Label1″ runat=”server”></asp:Label><asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” OnDataBinding=”CheckBoxList1_DataBinding”
OnDataBound=”CheckBoxList1_DataBound” Width=”168px”>
</asp:CheckBoxList></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

The ASP.Net CheckboxList Control OnDataBound Event Example output is :

ASP.Net CheckboxList Control OnDataBound Event Example with C#

ASP.Net CheckboxList Control OnDataBound Event Example with C#

STEP 2 – write below code on Button Click Event and OnDataBound Event of ASP.Net code page:

protected void Button1_Click(object sender, EventArgs e)
{
string[] Days = { “Sunday”, “Monday”, “Tusday”, “Wednesday”, “Thursday” };
CheckBoxList1.DataSource = Days;
CheckBoxList1.DataBind();
}
protected void CheckBoxList1_DataBound(object sender, EventArgs e)
{
Label1.Text = “Week Days”;
Label1.ForeColor = System.Drawing.Color.DarkBlue;
Label1.Font.Size = FontUnit.Medium;
CheckBoxList1.Items[1].Selected = true;
CheckBoxList1.Items[2].Selected = true;
CheckBoxList1.Items[4].Enabled = false;
}

The ASP.Net CheckboxList Control OnDataBound Event Example output is :

ASP.Net CheckboxList Control OnDataBound Event Example with C#

ASP.Net CheckboxList Control OnDataBound Event Example with C#

I hope this ASP.Net tutorials of Checkboxlist control OnDataBound Event will help you….