Checkboxlist control in asp net
Checkboxlist Asp.Net Control:
A checkboxlist is the
collection of squared object that allows to you to click on these given item
for selection. If the square is empty then it return false, and when you clicked,
the square would have a check mark and return true. And if again you do the square had a check
mark (clicked), the check mark would be removed from checkboxlist item checkbox.
The each item of checkboxlist (checked or unchecked has Boolean values) holds a Boolean value of true or false. When it
is not marked, then it has a value of false and when it is marked, then it has
a value of true.
ASP.net How to use Checkboxlist:
Creating checkboxlist on asp.net page. Checkboxlist
control enables to use to multi-selection check box in list.
<asp:CheckBoxList ID="chklstStates" runat="server">
</asp:CheckBoxList>
This
is example code for taking a checkboxlist on asp.net web page.
Create checkboxlist with list item:
<asp:CheckBoxList ID="check1" AutoPostBack="True" TextAlign="Right" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
<asp:ListItem>Item 6</asp:ListItem>
</asp:CheckBoxList>
Checkboxlist related other old post on asp.net tutorial:
- Validation checkbox control using JavaScript
- Asp-checkboxlist control demo:
- Asp checkboxlist Example using C#
- Checkboxlist in asp.net(control example)
- Example jQuery Validate on CheckBoxList using C#
- Check Uncheck all html CheckBoxlist controls using jQuery:
- Check Uncheck all asp.net CheckBox in asp.net using jQuery
- Ckeck box list example using javascript.
- Asp.net checkboxlist control example
- How to use CheckBox control in asp.net
- How to check If checkbox Is checked in asp.net
- Validation checkbox control using JavaScript:
- Checkbox list Example using javascript
- Asp.net Checkbox List.
- Get Asp.net CheckBoxList control values using Jquery
Asp.net c# CheckBoxList control example:
<%@ Page
Language="C#"
AutoEventWireup="true"
CodeFile="checkboxlist1aspx.aspx.cs"
Inherits="checkboxlist1aspx"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>ASP.net How to use Checkbox list control</title>
<style type="text/css">
div
{
margin:10px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
<div style="width:400px; float:left;">
<fieldset>
<h3> Checkbox
list control Example:</h3>
<p>List of State: select checkbox from this
checkboxlist control:</p>
<div>
<asp:CheckBoxList ID="chklstStates"
runat="server">
<asp:ListItem Text="Alabama"
Value="Alabama"></asp:ListItem>
<asp:ListItem Text="Alaska"
Value="Alaska"></asp:ListItem>
<asp:ListItem Text="Arizona"
Value="Arizona"></asp:ListItem>
<asp:ListItem Text="Arkansas"
Value="Arkansas"></asp:ListItem>
<asp:ListItem Text="California"
Value="California"></asp:ListItem>
<asp:ListItem Text="Connecticut"
Value="Connecticut"></asp:ListItem>
<asp:ListItem Text="Florida"
Value="Florida"></asp:ListItem>
<asp:ListItem Text="Delaware"
Value="Delaware"></asp:ListItem>
<asp:ListItem Text="Hawaii"
Value="Hawaii"></asp:ListItem>
<asp:ListItem Text="Kentucky"
Value="Kentucky"></asp:ListItem>
<asp:ListItem Text="Maryland"
Value="Maryland"></asp:ListItem>
<asp:ListItem Text="New Jersey"
Value="New
Jersey"></asp:ListItem>
<asp:ListItem Text="New York"
Value="New
York"></asp:ListItem>
</asp:CheckBoxList>
</div>
<asp:Button ID="btnSubmit"
runat="server"
Text="Submit"
OnClick="btnSubmit_Click"
/>
</fieldset>
</div>
<div style="width:289px; float:left;">
<fieldset style="width: 297px">
<h3>Selected States:</h3>
<p>selected checkbox from this checkboxlist</p>
<p> </p>
<div>
<asp:Label ID="lblStates"
runat="server"></asp:Label>
</div>
</fieldset>
</div>
</div>
</form>
</body>
</html>
CheckBoxList Control C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class checkboxlist1aspx
: System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
lblStates.Text = string.Empty;
}
protected void
btnSubmit_Click(object sender, EventArgs e)
{
foreach (ListItem
item in chklstStates.Items)
{
if (item.Selected)
lblStates.Text += item.Text + "<br>";
}
}
}
Other Importent Asp.net Related Post:
- How to Make Data Table By C# code in Asp.net Programming:
- how to add capcha in Asp.net programming
- how to use CAPTCHA in asp.net
- Example of Crystal report(Crystal_report_in asp.net programming )
- How to Make a HTML Table by C# code in asp.net programming
- Example jQuery Validate on CheckBoxList using C#
- Example of Templatefield in gridview .
- Example of DropDownList inside GridView
- Checkbox in ASP.NET GridView
- Ckeckboxlist example using javascript in gridview.
- Checkbox in ASP.NET GridView
- Show grid view row details in to tooltip.
- How to Bind Gridview Form database.
- Show gridview Row Details And Give Example.
- Example of Templatefield in asp.net gridview.
- Example of DropDownList inside GridView control
- Introduction of Asp.net grid view Control.
- Example of C# for Bind Data to asp.net Textbox inside gridview control
- Bind Data to asp.net textbox control in inside of gridview Using C# Example.
Comments
Post a Comment