带复选框列表的C#foreach循环 [英] C# foreach loop with check box lists

查看:113
本文介绍了带复选框列表的C#foreach循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有人



我试图遍历类/对象列表,如果它们存在于复选框列表中,则将状态设置为已签入这页纸。以下是我的代码





Hey Everyone

I am trying to loop through a list of classes/objects and if they exist in the checkbox list, then to set the state as checked in the page. Below is my code


if (storeLevelStamps != null && storeLevelStamps.Count > 0)
       {
           foreach (ListItem item in cbTagList.Items)
           {
               foreach (var stamp in (storeLevelStamps.Where(s => s.StampId == Convert.ToInt32(item.Value))))
                   item.Selected = true;
           }
       }





cbTagList是复选框列表,而storeLevelStamps是对象列表



任何帮助都会很棒



cbTagList is the checkbox list, while storeLevelStamps is the list of Objects

any help would be great

推荐答案

在另一个电话中调用了一个重置​​方法,一切都很棒!感谢上面代码的帮助
there was a call to a reset method inside a different call, all great! thanks for the help the code above works


这篇关于带复选框列表的C#foreach循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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