using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
public partial class ListControls : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<string> educationList = new List<string>();
educationList.Add("MBA");
educationList.Add("MCA");
educationList.Add("BE");
educationList.Add("B.Tech");
educationList.Add("B.Arch");
educationList.Add("PHD");
CheckBoxList1.DataSource = educationList;
CheckBoxList1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
sb.Append("</br>"+item );
}
}
Label1.Text ="You have selected :"+ sb.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
if (CheckBoxList1.RepeatDirection == RepeatDirection.Vertical)
{
CheckBoxList1.RepeatDirection = RepeatDirection.Horizontal;
}
else
{
CheckBoxList1.RepeatDirection = RepeatDirection.Vertical;
}
}
}