B
bebop
I'm using three checkbox web controls in C# .NET
and one button, and one labe
Is there a way to "group" these individual checkbox web controls
If so, do I use a for loop, hashtable, array, etc
What I'm looking for is how to determine what checkbox was selected from the three checkbox web controls and have the selected checkbox(es) display in a label
I don't want to use the following
if (CheckBox1.Checked == true
//do something
if (CheckBox2.Checked == true
//do somethin
and so fort
What if I had 50 Individual Checkbox web controls I don't want to have the above if statement 50 times in my code behind
I want to have something else-such as a loop that will iterate through the Individual Checkbox controls to check which is selected and print the selected out to the label
Can this be done without using CheckBoxList web control
Any suggestions would be appreciated
Thanks
bebo
code
<asp:CheckBox id="CheckBox1" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 32px" runat="server
Text="aaa"></asp:CheckBox><asp:CheckBox id="CheckBox2" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 64px" runat="server
Text="bbb"></asp:CheckBox><asp:CheckBox id="CheckBox3" style="Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 96px" runat="server
Text="ccc"></asp:CheckBox><asp:Button id="Button1" style="Z-INDEX: 104; LEFT: 40px; POSITION: absolute; TOP: 144px" runat="server
Text="Button"></asp:Button><asp:Label id="Label1" style="Z-INDEX: 105; LEFT: 176px; POSITION: absolute; TOP: 48px" runat="server"></asp:Label
******
and one button, and one labe
Is there a way to "group" these individual checkbox web controls
If so, do I use a for loop, hashtable, array, etc
What I'm looking for is how to determine what checkbox was selected from the three checkbox web controls and have the selected checkbox(es) display in a label
I don't want to use the following
if (CheckBox1.Checked == true
//do something
if (CheckBox2.Checked == true
//do somethin
and so fort
What if I had 50 Individual Checkbox web controls I don't want to have the above if statement 50 times in my code behind
I want to have something else-such as a loop that will iterate through the Individual Checkbox controls to check which is selected and print the selected out to the label
Can this be done without using CheckBoxList web control
Any suggestions would be appreciated
Thanks
bebo
code
<asp:CheckBox id="CheckBox1" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 32px" runat="server
Text="aaa"></asp:CheckBox><asp:CheckBox id="CheckBox2" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 64px" runat="server
Text="bbb"></asp:CheckBox><asp:CheckBox id="CheckBox3" style="Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 96px" runat="server
Text="ccc"></asp:CheckBox><asp:Button id="Button1" style="Z-INDEX: 104; LEFT: 40px; POSITION: absolute; TOP: 144px" runat="server
Text="Button"></asp:Button><asp:Label id="Label1" style="Z-INDEX: 105; LEFT: 176px; POSITION: absolute; TOP: 48px" runat="server"></asp:Label
******