[CLOSED] GetStore() on ComboBox with static ListItems wipes out the ListItem collection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] GetStore() on ComboBox with static ListItems wipes out the ListItem collection

    GetStore() on ComboBox with static ListItems wipes out the ListItem collection. Try to remove this line:

    Ext.Net.Store myStore = MyCombo.GetStore();
    ... and the sample will work with no exception.

    What's happening here?

    Thank you!

    -r-

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Data" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
    
            // this line will wipe out the ListItem collection
            Ext.Net.Store myStore = MyCombo.GetStore();
            //
            
            string value = MyCombo.SelectedItem.Value;
    
            if (string.IsNullOrEmpty(value))
            {
                Store store = MyCombo.GetStore();
    
                if (store != null)
                {
                    DataTable dt = null;
    
                    if (store.DataSource is DataTable)
                    {
                        dt = store.DataSource as DataTable;
                    }
    
                    if (store.DataSource is DataSet)
                    {
                        DataSet ds = store.DataSource as DataSet;
                        if (ds.Tables.Count > 0)
                        {
                            dt = ds.Tables[0];
                        }
                    }
    
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        value = Convert.ToString(dt.Rows[0][MyCombo.ValueField]);
                    }
                    else
                    {
                        value = MyCombo.Items[0].Value;
                    }
                }
            }
            
            // do something with value
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
                <ext:ComboBox
                    InputWidth="350"                                                                        
    
                    ID="MyCombo"
                    runat="server"
    
                    FieldLabel="MyCombo"
                    PreselectFirstItem="True"
                    EmptyText=""
                    Editable="false" 
                    QueryMode="Local"
                    TriggerAction="All" 
    
                    AllowBlank="false">
                                            
                    <Items>
                        <ext:ListItem Text="AAA" Value="1"  />
                        <ext:ListItem Text="BBB" Value="2" />
                        <ext:ListItem Text="CCC" Value="3" />
                    </Items>
    
                </ext:ComboBox>
            
        </form>
    </body>
    </html>
    Last edited by Daniil; Oct 31, 2015 at 8:34 AM. Reason: [CLOSED]

Similar Threads

  1. Replies: 0
    Last Post: Aug 12, 2014, 4:44 AM
  2. [CLOSED] Adding different Listitems to each ComboBox in Grid
    By blueworld in forum 2.x Legacy Premium Help
    Replies: 12
    Last Post: Mar 21, 2014, 1:26 PM
  3. [CLOSED] Can't add ListItems to ComboBox in codebehind [1.0]
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 18, 2012, 5:05 PM
  4. [CLOSED] ListItems / ComboBox - value is always a String?
    By wagger in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 31, 2011, 3:46 PM
  5. [CLOSED] adding listitems dynamically in a combobox
    By LeeTheGreek in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 22, 2009, 4:26 PM

Tags for this Thread

Posting Permissions