<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="Data" %>
Bullets & Radios
File: Default.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Data : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillOptions();
FillCountries();
}
}
protected void FillOptions()
{
BulletOptions.DataSource = Enum.GetValues(typeof(BulletStyle));
BulletOptions.SelectedIndex = 0;
BulletOptions.DataBind();
}
protected void FillCountries()
{
string connString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
string cmdText = "SELECT DISTINCT country FROM customers";
DataTable data = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter(cmdText, connString);
adapter.Fill(data);
BulletedList1.DataSource = data;
BulletedList1.DataTextField = "country";
BulletedList1.DataBind();
}
protected void BulletOptions_SelectedIndexChanged(object sender, EventArgs e)
{
BulletStyle style = (BulletStyle) Enum.Parse(typeof(BulletStyle), BulletOptions.SelectedValue);
BulletedList1.BulletStyle = style;
}
}