Please find the code block below.
<asp:Button Text="Click Me" ID="btn" runat="server" OnClick="btn_Click" />
<asp:Panel ID="Panel1" runat="server">
<asp:CheckBox Text="1" runat="server" ID="chk1" />
<asp:CheckBox Text="2" runat="server" ID="chk2" />
<asp:CheckBox Text="3" runat="server" ID="chk3" />
<asp:CheckBox Text="4" runat="server" ID="chk4" />
<asp:CheckBox Text="5" runat="server" ID="chk5" />
<asp:CheckBox Text="6" runat="server" ID="chk6" />
<asp:CheckBox Text="7" runat="server" ID="chk7" />
<asp:CheckBox Text="8" runat="server" ID="chk8" />
<asp:CheckBox Text="9" runat="server" ID="chk9" />
<asp:CheckBox Text="10" runat="server" ID="chk10" />
</asp:Panel>
<asp:Label Text="" ID="lbl" runat="server" />
Below is the code behind
protected void btn_Click(object sender, EventArgs e)
{
List<int> values = new List<int>();
foreach (Control item in Panel1.Controls)
{
if (item.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))
{
CheckBox c = (CheckBox)item;
if (c.Checked)
values.Add(Convert.ToInt16(c.Text));
}
}
if (values.Count > 0)
{
values.Sort();
lbl.Text = values[0] + " - " + values[values.Count - 1];
}
}