关于ListBox的问题
我想用ListBox实现选择多项内容进行查询的功能,现在已经知道SelectionMode可以设置多项选择,但是不知道怎么能取到这些值,用Response.Write(listBox.SelectedValue);
只能打出所选项目中的第一个值,请问怎么才能我所选择的全部项呢?

研究多日未果,谢谢各位了先。

2006-01-18 15:24
选择的项在ListBox.SelectedItems中
ArrayList temp=new ArrayList();
for(int i=0;i<this.listBox1.SelectedItems.Count;i++)
{
temp.Add(this.listBox1.SelectedItems[i]);
}

2006-01-18 15:35

2006-01-18 16:35
2006-01-18 16:50
你要早说是web下的啊,我还以为是form下的呢
在web下的话遍历所有item,判断是否被选择了,然后挑出
ArrayList temp=new ArrayList();
for(int i=0;i<this.ListBox1.Items.Count;i++)
{
if(this.ListBox1.Items[i].Selected==true)
temp.Add(this.ListBox1.Items[i]);
}

2006-01-18 17:07

2006-01-18 17:25
2006-01-18 17:27
2006-01-18 18:04