ASP Net Controls ASP.Net Tutorial

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
    Inherits="CheckAndRadioLists" %>



    Using CheckBoxList and RadioButtonList


   
   
      

CheckBoxList and RadioButtonList Demo


      
          Repeat Direction:
          
              Horizontal
              Vertical
          
          Repeat Layout:
          
              Table
              Flow
          
          Repeat Columns:
          
              1
              2
              3
          
          
          
      

      
          Crust:
          

          
              Thin
              Medium
              Thick
          
          Toppings:

                        RepeatDirection="Vertical" RepeatLayout="Table" RepeatColumns="2">
              Ham
              Mushrooms
              Pepperoni
          
   
      
     
      

      
   

   


File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CheckAndRadioLists : System.Web.UI.Page
{
  protected void btnChange_Click(object sender, EventArgs e)
  {
    int columns = Convert.ToInt32(drpColumns.SelectedValue);
    rlstCrust.RepeatColumns = columns;
    clstToppings.RepeatColumns = columns;
    string sLayout = drpLayout.SelectedValue;
    RepeatLayout layout = (RepeatLayout)Enum.Parse(typeof(RepeatLayout), sLayout, true);
    rlstCrust.RepeatLayout = layout;
    clstToppings.RepeatLayout = layout;
    string sDirect = drpDirection.SelectedValue;
    RepeatDirection direct = (RepeatDirection)Enum.Parse(typeof(RepeatDirection), sDirect, true);
    rlstCrust.RepeatDirection = direct;
    clstToppings.RepeatDirection = direct;
  }
  protected void btnOrder_Click(object sender, EventArgs e)
  {
    labMessage.Text = "Pizza Ordered: 
";
    labMessage.Text += rlstCrust.SelectedItem.Text;
    labMessage.Text += " Crust
Toppings:
";
    foreach (ListItem topping in clstToppings.Items)
    {
      if (topping.Selected)
      {
        labMessage.Text += topping.Text + "
";
      }
    }
  }
}