简单问题 问下大家
数据库提出
string a= "款式:大,小,中 ";
如何在下拉菜单中显示只
大
中
小
------解决方案--------------------protected void Page_Load(object sender, EventArgs e)
{
string a = "款式:大,中,小 ";
string[] b = a.Split( ': ');
string[] c = b[1].Split( ', ');
CheckBoxList CBL = new CheckBoxList();
CBL.ID = "CBL ";
CBL.DataSource = c;
CBL.DataBind();
DropDownList DDL = new DropDownList();
DDL.DataSource = c;
DDL.DataBind();
this.Form.Controls.Add(CBL);
this.Form.Controls.Add(DDL);
}
protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList CBL = (CheckBoxList)this.Form.FindControl( "CBL ");
foreach (ListItem LI in CBL.Items)
{
if (LI.Selected)
Response.Write(LI.Text);
}
}