在每次检查时保存复选框列表项的值

发布于 2025-01-03 08:33:30 字数 267 浏览 5 评论 0原文

我有一个包含 9 个项目的复选框列表..

用户可以检查的最大检查数量只有 3....

我该如何做类似的事情...

(1) 在第一次检查时,将项目值存储在labelA..

(2) 第2次检查时,将项目值存储在labelB中..

(3) 第3次检查时,将项目值存储在labelC中..

(4) 用户每次检查任何时间,执行actionA,其中将利用储值从3个标签?

请帮忙...我需要在今天之前完成它...

I have a checkboxlist containing 9 items..

The max no of checks that a user can check is only 3....

How do I go about doing something like...

(1) on the 1st check, store the item value in labelA..

(2) on the 2nd check, store the item value in labelB..

(3) on the 3rd check, store the item value in labelC..

(4) Each time the user check on any time, perform actionA which will make use of the store value from the 3 labels?

pls help... I need to get it done by today...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

榕城若虚 2025-01-10 08:33:30

您需要设置AutoPostBack=True并处理CheckBoxList控件的SelectedIndexChanged事件。

You need to set AutoPostBack=True and handle SelectedIndexChanged event of CheckBoxList control.

半窗疏影 2025-01-10 08:33:30

只需使用计数器即可。每次选中一个复选框时,增加该数字,如果等于 3,则将其回滚到 0。

 switch(counter)
 {
 case 0:
   label1.text = checkboxJustChecked.text;    
   break;
 (and so on)
 }
counter++;
if(counter>=3)
   counter=0;

要使您只能选中 3 个,请有一个包含最后 3 个复选框的队列,然后取消选中队列中最旧的复选框当检查一个新的时。

Just use a counter. Every time a checkbox is checked, increase that number and roll it back to 0 if it's equal to 3.

 switch(counter)
 {
 case 0:
   label1.text = checkboxJustChecked.text;    
   break;
 (and so on)
 }
counter++;
if(counter>=3)
   counter=0;

To make it so that you can only check 3, have a queue of the last 3 checkboxes and then uncheck the oldest checkbox in the queue when a new one is checked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文