Multiple selected items in ListBox.

<asp:ListBox ID="ListBox1" SelectionMode="Multiple"  runat="server">
<asp:ListItem>one</asp:ListItem>
<asp:ListItem>two</asp:ListItem>
<asp:ListItem>three</asp:ListItem>
</asp:ListBox>

private void GetSelectedItems()
{
string[] str = { "one", "three" };
foreach (string item in str)
{
for (int i = 0; i <= ListBox1.Items.Count - 1; i++)
{
if (ListBox1.Items[i].Text == item)
{ ListBox1.Items[i].Selected = true; }
}
}
}
Ebook Download
View all
Learn
View all