Combobox.SelectedItems null value

  1. #1

    Combobox.SelectedItems null value

    Hi,

    i'm trying use combobox... I can't get selectedvalues (or selectedtext) into procedure also combobox.items is null after change combo.
    P.s. browser show same rows in combobox list for selection

    see code below:


    <ext:ComboBox runat="server" ID="cmb_shift" FieldLabel="Смена" Width="600" LabelWidth="200"
                    Style="margin-left: 50px; margin-top: 10px"
                    DisplayField="TEXT_VALUE"
                    ValueField="INTEGER_VALUE"
                    ForceSelection="true"
                    QueryMode="Remote"
                    MultiSelect="false"
                    >
                    <Store>
                        <ext:Store runat="server" ID="Store_shift">
                            <Model>
                                <ext:Model runat="server" IDProperty="DEV_ID">
                                    <Fields>
                                        <ext:ModelField Name="INTEGER_VALUE" Type="Int" />
                                        <ext:ModelField Name="TEXT_VALUE" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <DirectEvents>
                        <Change OnEvent="cmb_shift_change">
                        </Change>
                    </DirectEvents>
                </ext:ComboBox>
                string sql_shift = "My select command";
                DataTable table_shift = new DataTable();
                OracleDataAdapter oda_shift = new OracleDataAdapter(sql_shift, conn);
                oda_shift.SelectCommand.Connection.Open();
                oda_shift.Fill(table_shift);
                oda_shift.SelectCommand.Connection.Close();
                Store_shift.DataSource = table_shift;
  2. #2
    Hi @Nshikov,

    Welcome to the Ext.NET forums!

    Binding data to a ComboBox via its Store doesn't populate its Items.

    As for getting a selected item, here is an example.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.ComboBox1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "1", "Item 1" },
                    new object[] { "2", "Item 2" },
                    new object[] { "3", "Item 3" }
                };
            }
        }
    
        protected void ComboBox1_Change(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("ComboBox1_Change", this.ComboBox1.SelectedItem.Text).Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:ComboBox 
                ID="ComboBox1" 
                runat="server" 
                DisplayField="text" 
                ValueField="value">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="value" />
                                    <ext:ModelField Name="text" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Reader>
                            <ext:ArrayReader />
                        </Reader>
                    </ext:Store>
                </Store>
                <DirectEvents>
                    <Change OnEvent="ComboBox1_Change" />
                </DirectEvents>
            </ext:ComboBox>
        </form>
    </body>
    </html>
  3. #3
    The above example works correctly, but it does not fit me.
    My combo box should be filled dynamically different count of records from the database, depending on the other components of the form.
    Because list of constant values in datastore is not usable. What you can advise me?
  4. #4
    Well, you can bind any data to a ComboBox's Store, but its SelectedItem should be working still.

    Please clarify is your ComboBox inside a <form runat="server">? If it is not, then a selected item is not submitted to server automatically. And everything else, actually.

Similar Threads

  1. Replies: 1
    Last Post: Jun 17, 2015, 12:45 PM
  2. [CLOSED] Setting SelectedItems of a combobox from MVC Model
    By hikalkan in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 19, 2013, 10:50 AM
  3. Combobox SelectedItems by value icw store
    By prost in forum 2.x Help
    Replies: 1
    Last Post: Oct 23, 2012, 9:06 AM
  4. [CLOSED] multiselect set selecteditems
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 02, 2009, 7:09 PM
  5. Replies: 1
    Last Post: Jan 07, 2009, 1:38 PM

Tags for this Thread

Posting Permissions