I'm dynamically adding checkboxes in the Page_Load (regardless of PostBack).
When IsPostBack, the checkboxes display as I expected and their
checked/unchecked status is also as expected. At this point, I want to find
particular checkboxes and determine whether they are check/unchecked, but
the code only returns that all the checkboxes are unchecked.
void SaveModel(Contr ol parent)
{
// spin through controls recursively
foreach (Control c in parent.Controls )
{
if (c.ID != null && c.ID.IndexOf("c bxModel") >= 0)
{
// ? ((CheckBox).c). Text displays the correct value at this
point, BUT.....
//-->this is not detecting the box checked although it's
clearly checked in the browser
if (((CheckBox)c). Checked == true)
{
//save to db here
}
}
if (c.Controls.Cou nt 0)
{
SaveModel(c);
}
}
}
Thanks.
When IsPostBack, the checkboxes display as I expected and their
checked/unchecked status is also as expected. At this point, I want to find
particular checkboxes and determine whether they are check/unchecked, but
the code only returns that all the checkboxes are unchecked.
void SaveModel(Contr ol parent)
{
// spin through controls recursively
foreach (Control c in parent.Controls )
{
if (c.ID != null && c.ID.IndexOf("c bxModel") >= 0)
{
// ? ((CheckBox).c). Text displays the correct value at this
point, BUT.....
//-->this is not detecting the box checked although it's
clearly checked in the browser
if (((CheckBox)c). Checked == true)
{
//save to db here
}
}
if (c.Controls.Cou nt 0)
{
SaveModel(c);
}
}
}
Thanks.