Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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


C#
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 is the checkbox list, while storeLevelStamps is the list of Objects

any help would be great
Posted
Comments
Ron Beyer 1-Jul-13 22:03pm    
So what is the problem? You told us what you are doing, but not what the issue is...
bobb024 1-Jul-13 22:05pm    
the problem is that the check boxes are not maintaining the check after looping through the list, all the items in my test case should be set to true and they are getting marked as true but nothing is maintaining that checked state

1 solution

there was a call to a reset method inside a different call, all great! thanks for the help the code above works
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 1-Jul-13 23:24pm    
You should not put such content as "solution".
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900