复选框选择问题,我只能选择2个复选框 [英] Checkbox selections problem, I can only select 2 checkboxes
本文介绍了复选框选择问题,我只能选择2个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有关如何选择我的复选框的问题,我已经成功编写了它的保存部分,但在选择和取消选中复选框时遇到问题
这一个只允许我取消选择一个复选框,我已经尝试嵌套但是我迷失了中间,我很感激你的回复。
这里是我的代码背后:< br $> b $ b
I have problem on how to select my checkboxes, I have successfully programed the saving part of it but having problem on the selecting and deselcting of checkboxes
this one only allows me to deselect one checkboxes, I have already tried nested if but I got lost in the middle, I would appreciate your response.
here's my code behind:
protected void chkActivity_CheckedChanged(object sender, EventArgs e)
{
if (chkActivity.Checked == false)
{
chkItem.Checked = true;
chkService.Checked = true;
}
else
{
chkAll.Checked = false;
chkActivity.Checked = false;
}
}
推荐答案
从else块中删除这段代码并尝试一下。 />
?
Remove this piece of code from else block and give it a try.
chkActivity.Checked = false;
您好,
在这里,您只显示代码的一小部分,所以我认为它可能是由于其他复选框的调用事件导致的,这些事件实际上是从您的代码中设置的,并且自行调用它们的事件。
Hello,
Here, you display very little portion of your code, so I think it may cause due to call event of other check-box which is actually set from your code and do itself to call their event automatically.
这篇关于复选框选择问题,我只能选择2个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文