Bind asp:Label with asp:ListBox (VB.net) : ListBox « ASP.net Controls « ASP.NET Tutorial






<script language="VB" runat="server">
   sub Index_Changed(Sender as Object, e as EventArgs)
      DataBind()
   end sub
</script>

<html><body>
   <form runat="server">
      <asp:Listbox runat="server" id="lbColors"
         AutoPostBack=true
         rows="1"
         SelectionMode="Single"
         OnSelectedIndexChanged="Index_Changed" >
         <asp:Listitem value="1">Red</asp:Listitem>
         <asp:Listitem value=" 2">Blue</asp:Listitem>
         <asp:Listitem value=" 3">Green</asp:Listitem>
         <asp:Listitem value=" 4">Yellow</asp:Listitem>
      </asp:Listbox>

      <asp:Label id="lblMessage" runat="server"
         Text='<%# lbColors.selectedItem.Text %>' />
   </form>
</body></html>








3.16.ListBox
3.16.1.asp:ListBox OnSelectedIndexChanged event and AutoPostBack (VB.net)
3.16.2.Fill value to asp:ListBox in asp:RadioButtonList selection changed action (VB.net)
3.16.3.Bind array data to asp:ListBox (VB.net)
3.16.4.Bind asp:Label with asp:ListBox (VB.net)
3.16.5.Set array value to asp:ListBox DataSource (VB.net)
3.16.6.Selection mode of asp:ListBox (C#)
3.16.7.Selection mode of asp:ListBox (VB)
3.16.8.Using the ListBox control (C#)
3.16.9.Using the ListBox control (VB)
3.16.10.Property tester