Nov 29, 2010, 5:31 PM
[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
Default.aspx.vb
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]