Selecting multiple values in Multiselect

  1. #1

    Selecting multiple values in Multiselect

    Hello there,
    string value="[2,3]";
    cmbMultiSelect.SetValue(value);

    I am using the above C# code to set multiple values in a multiselect control. But it is not working.
    Can you please help with the code to select multiple values in multiple select on a page load event?
    thanks
  2. #2
    Hi,

    Please populate SelectedItems during Page_Load and use SetValue during a DirectEvent.

    Eaxmple
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.MultiSelect1.SelectedItems.Add(new SelectedListItem("1"));
                this.MultiSelect1.SelectedItems.Add(new SelectedListItem("3"));
            }
        }
        
        protected void SetValues(object sender, DirectEventArgs e)
        {
            this.MultiSelect1.SetValue("2,4");
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:MultiSelect ID="MultiSelect1" runat="server">
                <Items>
                    <ext:ListItem Text="Item1" Value="1" />
                    <ext:ListItem Text="Item2" Value="2" />
                    <ext:ListItem Text="Item3" Value="3" />
                    <ext:ListItem Text="Item4" Value="4" />
                </Items>
            </ext:MultiSelect>
            <ext:Button runat="server" Text="Set '2,4' values" OnDirectClick="SetValues" />
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Multi-combo not selecting values after formpanel loads
    By jlosi in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 11, 2012, 6:33 PM
  2. Replies: 2
    Last Post: Mar 15, 2012, 6:04 AM
  3. [CLOSED] Problem with selecting values in gridpanel.
    By tlfdesarrollo in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jan 16, 2012, 1:38 PM
  4. [CLOSED] # Selecting TreePanel Nodes based on Store Values
    By webppl in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 01, 2011, 1:12 PM
  5. [CLOSED] Selecting all items in a MultiSelect dynamically
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 19, 2009, 7:14 AM

Tags for this Thread

Posting Permissions