<asp:CheckBoxList id='CheckBoxList1' runat='server'>
<asp:ListItem Value='Faq'>Faq</asp:ListItem>
<asp:ListItem Value='Tips'>Tips</asp:ListItem>
<asp:ListItem Value='Tricks'>Tricks</asp:ListItem>
</asp:CheckBoxList>
<asp:Button id='btnShow' style='Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 136px' runat='server'
Text='Show'></asp:Button>
VB.NET
Private Sub btnShow_Click(sender As Object, e As System.EventArgs)
Dim strchklist As String = ''
Dim li As ListItem
For Each li In CheckBoxList1.Items
If li.Selected Then
strchklist += li.Text + ' '
End If
Next
If strchklist = '' Then
Response.Write('No item Selected')
Else
Response.Write(('You selected : ' + strchklist))
End If
End Sub ’btnShow_Click
C#
private void btnShow_Click(object sender, System.EventArgs e)
{
string strchklist='';
foreach (ListItem li in CheckBoxList1.Items )
{
if (li.Selected )
{
strchklist += li.Text + ' ' ;
}
}
if (strchklist =='')
{
Response.Write ('No item Selected');
}
else
{
Response.Write ('You selected : ' + strchklist);
}
}
Share with