CheckBoxList
Previous | Home | Next |
The CheckBoxList Web server control displays a number of checkboxes at once. This control provides a multi selection check box group that can be dynamically generated with data binding. It contains an Items collection with members that correspond to individual items in the list. To determine which items are checked, we need to test the Selected property of each item in the list. The class hierarchy for his control is as follows: Object Control WebControl ListControl CheckBoxList Some Properties: 1.Items ::Gets/Sets the collection of items in the list 2.RepeatColumns ::Gets/Sets the number of displayed columns in the check box list 3.RepeatDirection ::Gets/Sets the display direction of checkboxes 4.RepeatLayout ::Gets/Sets the checkbox layout 5.TextAlign ::Gets/Sets the check box's text alignment
CheckBoxList *********************************************************************** <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckBoxList.aspx.cs" Inherits="_Default" %>********************************************************************** CS Code for RadiobuttonList ********************************************************************* using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Submit_Click(object sender, EventArgs e) { for (int i = 0; i < 2; i++) { if (CheckBoxList1.Items[i].Selected) { Show.Text = "Your Gender is: " + CheckBoxList1.Items[i].Text.ToString(); } } } }CheckBoxList
Previous | Home | Next |