I am attempting to loop through an array of numbers, match them to the checkbox they they are associated with, and checkmark that box.
My checkbox is set up like:
<input type="checkbox" runat="server" id="someID" name="somename" value="1234" />
My code when the page loads currently looks like:
foreach (string interest in interests_Var){
foreach (var c in Page.Controls)
{
}
}
interests_Var is my array containing different numbers. We'll assume one of them is 1234. While looping through the page controls, I want to compare the value of the control to my number. If it equals my number, I want to then apply the attribute checked="checked". I'm assuming I have to find the ID of the control I am using, then use that ID to add a new attribute. Or is there a way I can add the attribute using the c variable?
I'm not dead set on this setup, so if you know a better way, I'm all ears. Thanks for any help and suggestions.