检查ASP.NET的CheckBoxList多个项目 [英] Check multiple items in ASP.NET CheckboxList
本文介绍了检查ASP.NET的CheckBoxList多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试检查在ASP.NET中的CheckBoxList多个值,但我不能。
结果
我写道:
I try to check multiple values in ASP.NET CheckboxList but I couldn't.
I Wrote :
chkApplications.SelectedValue = 2;
chkApplications.SelectedValue = 6;
但它只是与价值选择项'6'结果
怎么了?
But it just selects item with value '6'
What's wrong ?
推荐答案
这会为你工作的最好的方法如下:
The best technique that will work for you is the following:
chkApplications.Items.FindByValue("2").Selected = true;
chkApplications.Items.FindByValue("6").Selected = true;
或者你可以简单做到像...
OR you can simply do it like...
foreach (ListItem item in chkApplications.Items)
{
if (item.Value == "2" || item.Value == "6")
{
item.Selected = true;
}
}
这篇关于检查ASP.NET的CheckBoxList多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文