将ArrayList中的ListItem绑定到DropDownList中去

DropDownListDisplay(ArrayList Input,DropDownList Inputddl, string CompareValue)

{

for(int i = 0;i<Input.Count;i++)

{

ListItem aItem = Input[i] as ListItem;

Inputddl.Items.Add(aItem);

}

if(CompareValue != "") Inputddl.SelectedIndex = Inputddl.IndexOf (Inputddl.Items.FindByVlue(CompareValue));

}

参数:ArrayList,需要绑定的数据

DropDownList,被绑定的下拉列表

CompareValue,一个string型的比较参数,用来设置下拉列表初始选项

Published At
Categories with Web编程
Tagged with
comments powered by Disqus