I am creating dynamic graphical checkboxes based on my database values inside a panel. but when i try to change the checked state while clicking on the select All checkbox. Nothing happens. I cannot find any controls inside that.
<div style="overflow: auto; height: 462px; width: 386px; margin-top: 0px;">
<asp:Panel ID="optionPanel" runat="server" Height="479px" Width="380px">
<cc1:GraphicalCheckBox ID="chkSelectAll" runat="server" CheckedImg="images/checked.gif" OnCheckedChanged="chkSelectAll_CheckedChanged"
UncheckedImg="images/unchecked.gif" UncheckedOverImg="images/unchecked.gif" CheckedOverImg="images/checked.gif"
UncheckedDisImg="images/unchecked_disabled.gif" Style="cursor: hand;" Font-Size="100%" AutoPostBack="true"/>
<span class="survey_wizard_title" id="lblSelectAll" runat="server">Select All</span>
</asp:Panel>
</div>
`
foreach (OptionPool opt in respOptions)
{
Panel row = new Panel();
GraphicalCheckBox cb = new GraphicalCheckBox();
row.Attributes.Add("class", "surveyCheckbox");
cb.ID = Convert.ToString(opt.id);
cb.Attributes.Add("value", opt.id.ToString());
cb.Text = opt.data;
cb.Style.Add("cursor", "hand");
cb.Font.Size = new FontUnit("100%");
cb.UncheckedImg = "images/unchecked.gif";
cb.UncheckedOverImg = "images/unchecked.gif";
cb.CheckedImg = "images/checked.gif";
cb.CheckedOverImg = "images/checked.gif";
cb.UncheckedDisImg = "images/unchecked_disabled.gif";
row.Controls.Add(cb);
optionPanel.Controls.Add(row);
}
protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)
{
if (chkSelectAll.Checked == true)
{
foreach (Control child in optionPanel.Controls)
{
if (!(child is GraphicalCheckBox))
continue;
if ((child is GraphicalCheckBox))
{
(child as GraphicalCheckBox).Checked = true;
}
}
}
}
optionPanel.control doesn't list any of the above dynamically created checkboxes.
Aucun commentaire:
Enregistrer un commentaire