<asp:listbox id='ListBox1' runat='server' selectionmode='Multiple'>
<asp:listitem value='Red'>Red</asp:listitem>
<asp:listitem value='Blue'>Blue</asp:listitem>
<asp:listitem value='Green'>Green</asp:listitem>
<asp:listitem value='White'>White</asp:listitem>
</asp:listbox>
<asp:radiobutton id='RadioButton1' runat='server' groupname='selrb' text='Select All' autopostback='True'></asp:radiobutton>
VB.NET
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Dim lstItem As ListItem
For Each lstItem In ListBox1.Items
lstItem.Selected = True
Next
End Sub
C#
foreach (ListItem lstItem in ListBox1.Items)
{
lstItem.Selected = true;
}
Share with