J
J
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(Control parent)
{
// spin through controls recursively
foreach (Control c in parent.Controls)
{
if (c.ID != null && c.ID.IndexOf("cbxModel") >= 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.Count > 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(Control parent)
{
// spin through controls recursively
foreach (Control c in parent.Controls)
{
if (c.ID != null && c.ID.IndexOf("cbxModel") >= 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.Count > 0)
{
SaveModel(c);
}
}
}
Thanks.