要求!
ListBox可以多选!我就是想获取ListBox多选的那几个被选中的数据!如何获得的到!用一个数组来存取这些多选的数据!
然后传值到另外一个页面!请各位帮帮忙!?拜托了!
例如!ListBox有一下数据!
00000
11111
22222
33333
44444
55555
66666
结果数据:
00000
22222
44444
66666
等数据被选中!
请问怎么获取到这些被选中的数据!???????
ListBox可以多选!我就是想获取ListBox多选的那几个被选中的数据!如何获得的到!用一个数组来存取这些多选的数据!
然后传值到另外一个页面!请各位帮帮忙!?拜托了!
例如!ListBox有一下数据!
00000
11111
22222
33333
44444
55555
66666
结果数据:
00000
22222
44444
66666
等数据被选中!
请问怎么获取到这些被选中的数据!???????
for (int i=0;i<this.ListBox1.Items.Count;i++)
{
if (this.ListBox1.Items[i].Selected) str+=this.ListBox1.Items[i].Text+",";
}
把str从浏览器参数的方式传过去,然后在另外个页面用split(str,",")分割成数组取值.
{ ArrayList al = new ArrayList();
for (int i = 0; i < ListBox1.Items.Count; i++)
{
if (ListBox1.Items[i].Selected)
al.Add( ListBox1.Items[i].Value);
} Array a = al.ToArray(); for (int i = 0; i < a.Length;i++ )
Response.Write(a.GetValue(i));
}
将得到的值用,号分开 成为一个string的变量 传到另外一个页面 在用Split(',')方法放到数组里边
然后遍历 string [] str=传过来的值.Split(','); 在循环数组
{
if (item.Selected) list.Add(item.Text);
}