选择在asp.net列表框中的所有项目 [英] select all items in the listbox in asp.net

查看:97
本文介绍了选择在asp.net列表框中的所有项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果复选框,单击我需要在asp.net列表框中选择所有项目...

if checkbox is clicked i need to select all items in the listbox in asp.net...

如何显示列表框中所有选定一旦全选复选框被点击的项目

how to show the items all selected in listbox once the 'selectall' checkbox is clicked

推荐答案

在复选框的的CheckedChanged 事件处理程序,遍历列表中的所有项目,并设置所选属性对所有为真。你还需要确保,多选择在你的列表框启用。使用以下方法来做到这一点:

In the CheckedChanged event handler of the checkbox, iterate through all the items of the list and set the Selected property for all as true. You also need to make sure that the multi selection is enabled on your listbox. Use the following to do that:

...
for(int i=0;i<ListBox1.Items.Count;i++)
{
    ListBox1.Items[i].Selected = true;
}
...

这篇关于选择在asp.net列表框中的所有项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆