I cannot find the checkboxes within Panel. Here is my code. On page load I add dynamically controls. It loads all controls properly:
if(!Page.IsPostBack){
foreach (var chk in chks)
{
PlSettings.Controls.Add(new LiteralControl("<div class=\"Controls\">"));
PlSettings.Controls.Add(chk);
PlSettings.Controls.Add(new LiteralControl("</div>"));
}
}
On button update, I would like to loop through all controls within panel, and if type of checbox, check if it's checked or not.
foreach (var panelctrl in PlSettings.Controls)
{
if (panelctrl.GetType() == typeof(CheckBox))
{
var checkbox = (CheckBox)chk;
if (checkbox.Checked)
{
userSettings.Add(Convert.ToInt32(checkbox.ID));
}
}
}
For some reason Panel has only one literal control. and no controls within.