I have a problem here, Basically. .
- I have a loop which has a list of sites, im going through each and every site.
- I have another loop which only contains some sites
- I want to return only the sites where the attribute t.title == F.title
- If this is true I want to tick a check box
- if not then dont tick a check box
The problem is, it keeps creating more checkboxes than I want, I only want the ones where there are matches ticked – the rest unticked?
foreach (Admin.DTO.SiteMap t in sites)
{
for each (Admin.DTO.SmallSites f in smallsites){
if (t.Title == f.Title)
{
myString1.Append(" <input type='checkbox' checked='yes' value='" + t.Title + "'/> ");
myString1.Append(t.Title);
}
else {
myString1.Append(" <input type='checkbox' value='" + t.Title + "'/> ");
myString1.Append(t.Title);
}
}
}
These two loop will create sites * smallsites checkboxs. With one few of it checked, many are not check in the rest.
Is this what you need?