Feb 22, 2013, 9:34 PM
"SqlDataSource" with combobox to select
Good afternoon,
I am working with two combos and two "SqlDataSource".
These are the following problems:
1. When selecting a value for the first time in the "ComboBox1" the value that was assigned to "ComboBox2" gives it null and not know why.
2. I select another value again, and in the "Listeners" and not heard so I can not call the method "reload ()" the "store".
V Ext.Net 2.1
server-side
I am working with two combos and two "SqlDataSource".
These are the following problems:
1. When selecting a value for the first time in the "ComboBox1" the value that was assigned to "ComboBox2" gives it null and not know why.
2. I select another value again, and in the "Listeners" and not heard so I can not call the method "reload ()" the "store".
V Ext.Net 2.1
server-side
<script runat="server">
protected void stCombo2_ReadData(object sender, StoreReadDataEventArgs e)
{
SqlCombo2.SelectParameters["id"].DefaultValue = ComboBox1.SelectedItem.Text;
}
</script>
the client side
<asp:SqlDataSource ID="SqlCombo2" runat="server" ConnectionString="<%$ ConnectionStrings:Conn %>"
SelectCommand="SELECT id, Name FROM Table2 WHERE id = @id">
<SelectParameters>
<asp:Parameter Name="id" DefaultValue="" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlCombo1" runat="server" ConnectionString="<%$ ConnectionStrings:Conn %>"
SelectCommand="SELECT id , Name FROM Table1" />
<ext:store id="stCombo2" runat="server" datasourceid="SqlCombo2" showwarningonfailure="false" onreaddata="stCombo2_ReadData">
<Model>
<ext:Model ID="Model2" runat="server" IDProperty="id"
Name="IdName">
<Fields>
<ext:ModelField Name="Id" Mapping="id" Type="Int" />
<ext:ModelField Name="Name" Mapping="Name" Type="String" />
</Fields>
</ext:Model>
</Model>
<Sorters>
<ext:DataSorter Property="id" Direction="ASC" />
</Sorters>
<Listeners>
<Load Handler="#{ComboBox2}.setValue(this.getAt(0).get(#{ComboBox2}.valueField));" /
</Listeners>
</ext:store>
<ext:store id="stCombo1" runat="server" datasourceid="SqlCombo1" showwarningonfailure="false">
<Model>
<ext:Model ID="Model3" runat="server" IDProperty="id"
Name="IdName2">
<Fields>
<ext:ModelField Name="id" Mapping="id" Type="Int" />
<ext:ModelField Name="Name" Mapping="Name" Type="String" />
</Fields>
</ext:Model>
</Model>
<Sorters>
<ext:DataSorter Property="id" Direction="ASC" />
</Sorters>
</ext:store>
<ext:panel runat="server" region="Center" width="400" height="400">
<Items>
<ext:ComboBox ID="ComboBox1" runat="server" StoreID="stCombo1" DisplayField="Name"
ValueField="Id" >
<Listeners>
<Select Handler="#{stCombo2}.reload(); #{ComboBox2}.clearValue();" />
</Listeners>
</ext:ComboBox>
<ext:ComboBox ID="ComboBox2" runat="server" StoreID="stCombo2" DisplayField="Name"
ValueField="Id" />
</Items>
</ext:panel>
Last edited by billy; Feb 22, 2013 at 9:37 PM.