Source Code
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>AA</asp:ListItem>
<asp:ListItem>BB</asp:ListItem>
<asp:ListItem>CC</asp:ListItem>
<asp:ListItem>DD</asp:ListItem>
</asp:CheckBoxList>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Text="Male" Value="0"></asp:ListItem>
<asp:ListItem Text="FeMale" Value="1"></asp:ListItem>
</asp:RadioButtonList>
<asp:Button ID="btnOK" runat="server" Text="OK" onclick="btnOK_Click"
ValidationGroup="k" />
<asp:Label ID="Label1" runat="server"></asp:Label>
<asp:Label ID="Label2" runat="server"></asp:Label>
C# Code
protected void btnOK_Click(object sender, EventArgs e)
{
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected)
{
}
else
{
Label2.Text = "Pls Select CheckBoxList";
}
}
foreach (ListItem l in RadioButtonList1.Items)
{
if (l.Selected)
{
}
else
{
Label1.Text = "Pls Select RadioButtonList";
}
}
}
No comments:
Post a Comment