I have a simple situation here. I have a web form with 'Accordion' which has some 'AccordionPanes' and in each AccordionPane there is some 'CheckBoxes'. About 30 checkboxes total.
Now I need to check the statuses of every checkboxes. and the question is how!? I was thinking about a 'for loop' and 'If Condition' like this:
for (i = 1; i <= 5; i++)
{
if (CheckBox(i).Checked)
{
Label1.Text = "yeepee!";
}
}
But looks like this is not a standard way to use 'if state' (and looks like I'm not a pro developer!). Now friends, Which way do you suggest?
for making the situation brighter, here is the HTML Code i'm using in my form:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Accordion ID="Accordion1"
runat="server"
HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent"
SelectedIndex="0"
FadeTransitions="false"
FramesPerSecond="40"
TransitionDuration="250"
AutoSize="Fill"
RequireOpenedPane="true"
SuppressHeaderPostbacks="true">
<Panes>
<asp:AccordionPane ID="AccordionPane1" runat="server">
<Header>
<h1>title</h1>
</Header>
<Content>
<asp:CheckBox ID="CheckBox1" runat="server" Text="sometext" />
<asp:CheckBox ID="CheckBox2" runat="server" Text="sometext" />
<asp:CheckBox ID="CheckBox3" runat="server" Text="sometext" />
<asp:CheckBox ID="CheckBox4" runat="server" Text="sometext" />
<asp:CheckBox ID="CheckBox5" runat="server" Text="sometext" />
<asp:CheckBox ID="CheckBox6" runat="server" Text="sometext" />
<asp:CheckBox ID="CheckBox7" runat="server" Text="sometext" />
</Content>
</asp:AccordionPane>
</Panes>
<Panes>
<asp:AccordionPane ID="AccordionPane2" runat="server">
<Header>
<h1>title</h1>
</Header>
<Content>
<asp:CheckBox ID="CheckBox8" runat="server" Text="sometext" />
<asp:CheckBox ID="CheckBox9" runat="server" Text="sometext" />
<asp:CheckBox ID="CheckBox10" runat="server" Text="sometext" />
</Content>
</asp:AccordionPane>
</Panes>
.
<!-- some more Panes and Checkboxes! -->
.
</asp:Accordion>
</ContentTemplate>
</asp:UpdatePanel>
And of course ASP.Net is the platform and C#.net is the language. Thank you and I'm looking forward to your answers. regards.
Edited:
My only problem is exactly this! you can't use checkboxes in a loop like this: Checkbox(i).Checked:
bool[] array = new bool[30];
for (int i = 0; i < 30; i++)
{
array[i] = CheckBox(i).Checked ;
}
I exactly want to know how can i use IDs of checkboxes with a variable, like:
i = 15;
CheckBox(i).Checked
instead of:
CheckBox15.Checked