Asp net listbox multiple selection
User-68639941 posted Show
public: virtual property System::Web::UI::WebControls::ListSelectionMode SelectionMode { System::Web::UI::WebControls::ListSelectionMode get(); void set(System::Web::UI::WebControls::ListSelectionMode value); }; public virtual System.Web.UI.WebControls.ListSelectionMode SelectionMode { get; set; } member this.SelectionMode : System.Web.UI.WebControls.ListSelectionMode with get, set Public Overridable Property SelectionMode As ListSelectionMode ListSelectionMode One of the ListSelectionMode values. The default value is Single. ExamplesThe following example illustrates how to use the SelectionMode property to allow the user to select multiple selections from the ListBox control. <%@ Page Language="C#" AutoEventWireup="True" %>ListBox Example<%@ Page Language="VB" AutoEventWireup="True" %>ListBox ExampleRemarksUse the SelectionMode property to specify the mode behavior of the ListBox control. Setting this property to ListSelectionMode.Single indicates only a single item can be selected from the ListBox control, while ListSelectionMode.Multiple specifies multiple items can be selected. The value of the SelectionMode property is stored in view state. Applies to
asp.net listbox get multiple selected items The following asp.net c# example code demonstrate us how can we get ListBox control's selected items programmatically when ListBox selection mode is multiple. ListBox control 'SelectionMode' property have two possible values 'Multiple' and 'Single'. Multiple mode allow us to select more than one items from ListBox control. When users select items from ListBox which SelectionMode is Multiple, then it is more complicated to get the selected items programmatically at run time. We can get ListBox selected items on ListBox SelectedIndexChanged event or manually by a Button click without AutoPostBack. To get the ListBox selected items, at first we perform a Linq query to get the ListBox items which ListItem object's 'Selected' property value is 'true'. Then we loop through the selected items collection and display on web browser with items text and value.. listbox-get-multiple-selected-items.aspx <%@ Page Language="C#" AutoEventWireup="true"%>
I can't find a way to select multiple items in an ASP.NET ListBox in the code behind? Is this something needs to be done in Javascript?
|