[CLOSED] Problem to multiselect in combo from code behind

  1. #1

    [CLOSED] Problem to multiselect in combo from code behind

    Hello

    I'm not able to tick items in multicombo from code behind.

    Here a case test :

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                var data = new object[]
                {
                    new {id = "A"},
                    new {id = "B"},
                    new {id = "C"},
                    new {id = "D"},
                    new {id = "E"},
                    new {id = "F"},
                    new {id = "G"},
                    new {id = "H"},
                    new {id = "I"},
                    new {id = "J"},
                    new {id = "K"},
                    new {id = "L"},
                    new {id = "M"},
                    new {id = "N"},
                    new {id = "O"},
                    new {id = "P"},
                    new {id = "Q"}
                };
    
                this.Store1.Data = data;
            }
        }
    
        void setD(object sender, EventArgs e)
        {
            Ext.Net.ListItem item = new Ext.Net.ListItem();
            item.Text="D";
            item.Value = "D";
            cbotest.Value = "D";
            cbotest.Items.Add(item);
        }
    
        void setBPQ(object sender, EventArgs e)
        {
            Ext.Net.ListItem item = new Ext.Net.ListItem();
            item.Text = "B";
            item.Value = "B";
            cbotest.Items.Add(item);
            item = new Ext.Net.ListItem();
            item.Text = "P";
            item.Value = "P";
            cbotest.Items.Add(item);
            item = new Ext.Net.ListItem();
            item.Text = "Q";
            item.Value = "Q";
            cbotest.Value = "B,P,Q";
            cbotest.Items.Add(item);
        }
    
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
                 <ext:MultiCombo ID="cbotest"
                    runat="server"
                    Editable="false"
                    FieldLabel="Status"
                    Enabled="True"
                    Name="Status"
                    DisplayField="id"
                    ValueField="id" >
                    <ListConfig ID="ListConfig9" runat="server" Cls="top-list">
                    </ListConfig>
                    <Store>
                        <ext:Store ID="Store1" runat="server" WarningOnDirty="false">
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="id" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                            <Sorters>
                                <ext:DataSorter Property="id" Direction="ASC" />
                            </Sorters>
                        </ext:Store>
                    </Store>
                </ext:MultiCombo>
            <ext:Button runat="server" Text="Set value D">
                <DirectEvents>
                    <Click OnEvent="setD"></Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button runat="server" Text="Set value BPQ">
                <DirectEvents>
                    <Click OnEvent="setBPQ"></Click>
                </DirectEvents>
            </ext:Button>
    
       </form>
    </body>
    </html>
    it works fine for 1 item but not for several.
    Last edited by Daniil; Dec 04, 2015 at 2:45 PM. Reason: [CLOSED]
  2. #2
    Hi @feanor91,

    Please use:
    void setD(object sender, EventArgs e)
    {
        cbotest.Value = "D";
    }
    
    void setBPQ(object sender, EventArgs e)
    {
        cbotest.Value = new string[] { "B", "P", "Q" };
    }

Similar Threads

  1. [CLOSED] Migration of MultiSelect loading in code behind
    By rmelancon in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 01, 2013, 4:42 PM
  2. Replies: 1
    Last Post: Dec 06, 2012, 1:28 AM
  3. Replies: 4
    Last Post: May 09, 2012, 9:24 PM
  4. [CLOSED] Proble with combobox in window
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 21
    Last Post: Apr 24, 2012, 11:25 AM
  5. [CLOSED] [1.0] Multiselect combo and no wrap
    By bsnezw in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 21, 2010, 3:58 PM

Posting Permissions