[CLOSED] Keep values in Combo Box after postback

  1. #1

    [CLOSED] Keep values in Combo Box after postback

    Hello,

    I have following code and after the location combox is selected, post back happens. But after post back, location combo box values no longer there. How can I keep the values in location combo box after postback.

    Default.aspx

    <asp:SqlDataSource ID="CityTownDS" runat="server" ConnectionString="<%$ ConnectionStrings:SiteConnectionString %>"
    SelectCommand="citytown" SelectCommandType="StoredProcedure" FilterExpression="active = 1"></asp:SqlDataSource>
    
    <asp:SqlDataSource ID="LocationDS" runat="server" ConnectionString="<%$ ConnectionStrings:SiteConnectionString %>"
    SelectCommand="location" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    
    <ext:Store runat="server" ID="CityTownListStore" DataSourceID="CityTownDS">
    <Reader>
    <ext:JsonReader IDProperty="c_id">
    <Fields>
    <ext:RecordField Name="c_id" Type="Int" Mapping="c_id" />
    <ext:RecordField Name="c_name" Type="String" Mapping="c_name" />
    </Fields>
    </ext:JsonReader>
    </Reader>
    </ext:Store>
    
    <ext:Store runat="server" ID="LocationListStore" DataSourceID="LocationDS" AutoLoad="false" OnRefreshData="loc_LocationRefresh">
    <DirectEventConfig>
    <EventMask ShowMask="false" />
    </DirectEventConfig>
    <Reader>
    <ext:JsonReader IDProperty="l_id">
    <Fields>
    <ext:RecordField Name="l_id" Type="Int" Mapping="l_id" />
    <ext:RecordField Name="l_name" Type="String" Mapping="l_name" />
    </Fields>
    </ext:JsonReader>
    </Reader>
    </ext:Store>
    
    <ext:FieldSet ID="FieldSet1" runat="server" Title="Search by Location" Collapsible="true" Layout="form">
    <Items>
    <ext:CompositeField ID="CompositeField1" runat="server" FieldLabel="City / Town">
    <Items>
    <ext:ComboBox ID="CityTownComboBox" StoreID="CityTownListStore" Width="250" runat="server" Editable="True" TypeAhead="true" Mode="Local" ForceSelection="true" TriggerAction="All" SelectOnFocus="true" DisplayField="c_name" ValueField="c_id"  EmptyText="invalid city town">
    <Listeners>
    <Select Handler="#{LocationComboBox}.clearValue(); #{LocationListStore}.reload();" />
    </Listeners>
    </ext:ComboBox>
    </Items>
    </ext:CompositeField>
                                        
    <ext:CompositeField ID="CompositeField2" runat="server" FieldLabel="Location">
    <Items>
    <ext:ComboBox ID="LocationComboBox" StoreID="LocationListStore" width="250" runat="server" EmptyText="Loading..."
     ValueNotFoundText="No location" TypeAhead="true" Mode="Local" ForceSelection="true" TriggerAction="All"  DisplayField="l_name" ValueField="l_id" AutoPostBack="true" AutoPostBackEvent="Select">
    </ext:ComboBox>
    </Items>
    </ext:CompositeField>
    </Items>
    </ext:FieldSet>

    Default.aspx.vb

    Protected Sub LocationComboBox_ItemSelected(ByVal sender As Object, ByVal e As System.EventArgs) Handles LocationComboBox.ItemSelected
            ViewState("l_id") = LocationComboBox.SelectedItem.Value
    End Sub
    Last edited by geoffrey.mcgill; Nov 30, 2010 at 7:48 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please wrap any code in [CODE ] tags, see the link below.

    I see it's your second post on the forum. So, please, when you have a chance please read
    http://forums.ext.net/showthread.php...ing-New-Topics

    Regarding the question

    Please clarify why do you need AutoPostBack="true" for ComboBox?
    Last edited by geoffrey.mcgill; Nov 29, 2010 at 6:11 PM.
  3. #3
    Hi,

    I guess that you have to rebind the store
    protected void Page_Load(object sender, EventArgs e)
    {
         if(!X.IsAjaxRequest)
         {       
              LocationListStore.DataBind();
         }
    }
  4. #4
    I am using ASP.NET calendar and requires postback to execute the functions for calendar.
  5. #5
    Quote Originally Posted by Vladimir View Post
    Hi,

    I guess that you have to rebind the store
    protected void Page_Load(object sender, EventArgs e)
    {
         if(!X.IsAjaxRequest)
         {       
              LocationListStore.DataBind();
         }
    }
    I tried this but still won't show.
    Thanks.
  6. #6
    Hi,

    Why do you have AutoLoad="false"? I think it prevents values loading

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. [1.2] Postback on null values with autosave
    By hc.dev in forum 1.x Help
    Replies: 4
    Last Post: Jan 04, 2012, 4:52 PM
  3. [CLOSED] Using values from multi column combo box
    By CarWise in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 19, 2010, 11:44 AM
  4. [CLOSED] Combo get values
    By CMA in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 04, 2009, 6:59 AM
  5. Combo - Populate with rowindex values
    By Tbaseflug in forum 1.x Help
    Replies: 1
    Last Post: Sep 21, 2009, 11:25 AM

Posting Permissions