Out Put :
ASPX.Net :
<asp:ListBox ID="ListBox1" runat="server" Height="130px"
OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" AutoPostBack="True"
SelectionMode="Multiple">
<asp:ListItem Value="1" Text="One"></asp:ListItem>
<asp:ListItem Value="2" Text="Two"></asp:ListItem>
<asp:ListItem Value="3" Text="Three"></asp:ListItem>
<asp:ListItem Value="4" Text="Four"></asp:ListItem>
<asp:ListItem Value="5" Text="Five"></asp:ListItem>
<asp:ListItem Value="6" Text="Six"></asp:ListItem>
<asp:ListItem Value="7" Text="Seven"></asp:ListItem>
<asp:ListItem Value="8" Text="Eight"></asp:ListItem>
<asp:ListItem Value="9" Text="Nine"></asp:ListItem>
</asp:ListBox>
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
C# :
{
Label1.Text = "Selected Values : "
+ String.Join(", ", ListBox1.Items.Cast<ListItem>().Where(i => i.Selected).Select(i => i.Value).ToArray()); ;
}
No comments:
Post a Comment