checkboxlist all通过更改单个复选框来检查true。 [英] checkboxlist all check true by change of single checkbox.

查看:78
本文介绍了checkboxlist all通过更改单个复选框来检查true。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我有一个复选框和复选框列表。我希望通过更改复选框来检查复选框列表的所有内容。我的代码: -



< asp:CheckBox ID =CheckBox1runat =server/>



 <   asp:CheckBoxList     ID   =  CheckBoxList1    runat   =  server    DataSourceID   =  SqlDataSource2    DataTextField   = 代码    DataValueField   =  departmentid  

< span class =code-attribute> RepeatColumns = 2 RepeatDirection = 水平 >
< / asp:CheckBoxList >







我该怎么办..

解决方案

试试

选中/取消选中CheckBoxList中的所有复选框 [< a href =http://www.codeproject.com/Tips/591696/Check-Uncheck-all-checkboxes-in-a-CheckBoxList\"target =_ blanktitle =New Window> ^ ]

选中取消选中所有项目在ASP.Net CheckBoxList中使用jQuery [ ^ ]


< blockquote>您好,



在复选框更改的活动中,您可以编写以下代码





if( checkBox .checked)

{

foreach(ListItem item in checkBoxlist.Items)

{

item .Selected = true;

}

}

其他

{

foreach(ListItem item in checkBoxlist.Items)

{

item .Selected = false;

}

}


Sir, i have a checkbox and checkboxlist. i want to true all check of checkboxlist by change of checkbox. My Code:-

<asp:CheckBox ID="CheckBox1" runat="server" />

<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="code" DataValueField="departmentid"

                    RepeatColumns="2"  RepeatDirection="Horizontal">
 </asp:CheckBoxList>




how can i do it..

解决方案

Try
Check/Uncheck all checkboxes in a CheckBoxList[^]
Check Uncheck all items in ASP.Net CheckBoxList using jQuery [^]


Hi,

In checkbox changed event you can write the below code


if(checkBox.checked)
{
foreach (ListItem item in checkBoxlist.Items)
{
item.Selected = true;
}
}
else
{
foreach (ListItem item in checkBoxlist.Items)
{
item.Selected = false;
}
}


这篇关于checkboxlist all通过更改单个复选框来检查true。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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