dropdownlist基本用法
1 基本数据绑定
#region DDL数据初始绑定
/// <summary>
/// DDL词典类别数据初始绑定
/// </summary>
void DDLTypeDataInitBind(DropDownList DDL)
{
DataSet ds = new DataSet();
ds = Business.DictionaryClass.GetList("");
DDL.DataSource = ds;
DDL.DataTextField = "Title";
DDL.DataValueField = "Id";
DDL.DataBind();
DDL.Items.Insert(0, new ListItem("--请选择词典类型--", "-1"));
}
2 大写26个字母绑定
/// <summary>
/// DDL首字母数据初始绑定
/// </summary>
/// <param name="DDL"></param>
void DDLFirstLettersInitBind(DropDownList DDL)
{
DDL.Items.Clear();
for (int i = 65; i <= 90; i++)
{
DDL.Items.Add(new ListItem(Convert.ToChar(i).ToString(), Convert.ToChar(i).ToString()));
}
DDL.Items.Insert(0, new ListItem("--请选择首字母--","-1"));
}