protected
void
Page_Load(
object
sender, EventArgs e)
{
if (!IsPostBack)
{
ArrayList arrl = new ArrayList();
arrl.Add("李明");
arrl.Add("王云");
arrl.Add("乐乐");
DropDownList1.DataSource= arrl; //将数据列表作为DropDownList1的数据源
DropDownList1.DataBind();
}
}
{
if (!IsPostBack)
{
ArrayList arrl = new ArrayList();
arrl.Add("李明");
arrl.Add("王云");
arrl.Add("乐乐");
DropDownList1.DataSource= arrl; //将数据列表作为DropDownList1的数据源
DropDownList1.DataBind();
}
}
2、多态添加下拉列表项
protected
void
Button1_Click(
object
sender, EventArgs e)
{
DropDownList4.Items.Add(TextBox1.Text.ToString());
}
{
DropDownList4.Items.Add(TextBox1.Text.ToString());
}
3、分别添加Text,Value值,与插入项
DropDownList4.Items.Add(
new
ListItem(
"
111
"
,
"
111
"
));
DropDownList4.Items.Add( new ListItem( " 122 " , " 122 " ));
DropDownList4.Items.Insert( 1 , new ListItem( " 222 " , " 222 " )); // 插入到第2个位置
DropDownList4.Items.Add( new ListItem( " 122 " , " 122 " ));
DropDownList4.Items.Insert( 1 , new ListItem( " 222 " , " 222 " )); // 插入到第2个位置