I have a listbox which contains item names, i want that when i click some item in the listbox, that item name should be displayed in the label. How can we do this ?
i tried by doimg this:
<ContentTemplate>
<asp:ListBox ID="ddlevents" runat="server" Height="250px" Width="226px" AutoPostBAck="true"
SelectionMode="Multiple" Font-Size="8pt" OnSelectedIndexChanged="ddlevents_SelectedIndexChanged" >
</asp:ListBox>
<asp:Label ID="lblevents" runat="server" Text=""></asp:Label>
</ContentTemplate>
protected void ddlevents_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (ListItem item in ddlevents.Items)
{
if (item.Selected)
{
lblevents.Text += "<li><b>" + item.Text + "<b></li>";
}
}
}
when i am selecting 2 events,it displays me multiple times.what wrong i am doing?