I am using VB. How to select mult iteams in listbox using backend code?
I have a listbox where user can select muti items.
How can I set so the value of "blue b" and "green g" is already selected? I tried setSelected but this method is not supported.
I also tried this below which kind of works. It does select 1 value but I need to able to select multi values.
I tried this also and it doesn't select any values.
I have a listbox where user can select muti items.
Code:
<asp:ListBox ID="lb" SelectionMode="multiple" runat="server" DataValueField="dv">
<asp:ListItem>red r</asp:ListItem>
<asp:ListItem>blue b</asp:ListItem>
<asp:ListItem>green g</asp:ListItem>
</asp:ListBox>
Code:
lb.SetSelected(1, True) lb.SetSelected(2, True)
Code:
lb.Text = "blue b" lb.Text = "green g"
I tried this also and it doesn't select any values.
Code:
lb.Text = "blue b green g"
Comment