G
Geoff Taylor
I have three drop down list controls on an asp.net 2.0 page. The first
drop down list displays a list of continents, the second displays a
list of countries and the third displays a list of provinces. All
three drop down lists are fed by data sources that use stored
procedures. The stored procedure for filling the Countries drop down
list uses a parameter for filtering the countries that should fill the
list, and the value for that parameter comes from the value of the
currently selected item in the Continents drop down list.
The provinces control is implemented in a similar way. It has a stored
procedure which takes a parameter to filter which provinces to
display. The value of the parameter comes from the value of the
selected country in the Countries drop down list.
So: The filter for provinces depends on the item selected for a
country. And the filter for countries depends on the item selected as
a continent. My problem is that I can change a continent by selecting
a new one in that drop down list, which in turn updates the list of
items available in the countries drop down list, BUT the provinces
drop down list is not updated to reflect the fact that the countries
list has changed because the continents list changed.
I was hoping that a series of controls which have a chain of
dependencies on each other would be smart enough to update properly,
but that does not appear to be so. Is there anything simple that I am
missing here. Maybe I need to handle an event of some sort and
implement a bit of server-side code to properly update the controls,
but I was hoping not.
The first time I run the page I get these values as the first entries
in the drop down lists:
Continent = Africa, Country = Algeria, Province = Adrar
If i then change the continent to Europe, I get:
Continent = Europe, Country = United Kingdom, Province = Adrar - so
the province totally missed the fact that the country has changed.
Any ideas anyone?
Thanks in advance,
Geoff Taylor
Code is below:
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td
class="InnerInterfaceTheme">
<table width="100%"
cellspacing="0" cellpadding="0" border="0">
<tr><td colspan="8"
height="10"></td></tr>
<tr>
<td nowrap
width="10"> </td>
<td nowrap
width="1">
<asp:Image
ID="Step1" Runat="server" ImageUrl="~/Img/step1.gif" />
</td>
<td
style="position : relative; top : -5px;"
class="FieldsText"> Where:
<aspropDownList ID="DropDownListContinents" Runat="server"
SourceID="SqlContinents"
DataTextField="ContinentName" DataValueField="pkContinentID"
AutoPostBack="True">
</aspropDownList>
<asp:SqlDataSource ID="SqlContinents" Runat="server"
SelectCommand="igyw_ContinentsSorted"
ConnectionString="<%$ ConnectionStringsBConnString %>">
</asp:SqlDataSource> >
<aspropDownList ID="DropDownListCountries" Runat="server"
DataSourceID="SqlCountries"
DataTextField="Country" DataValueField="pkCountryID"
AutoPostBack="True">
</aspropDownList>
<asp:SqlDataSource ID="SqlCountries" Runat="server"
SelectCommand="igyw_CountriesSorted"
ConnectionString="<%$ ConnectionStringsBConnString %>">
<SelectParameters>
<asp:ControlParameter Name="Continent" Type="Int32"
ControlID="DropDownListContinents"
PropertyName="SelectedValue"></asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource> >
<aspropDownList ID="DropDownListProvinces" Runat="server"
DataSourceID="SqlProvinces"
DataTextField="Province" DataValueField="pkProvinceID"
AutoPostBack="True">
</aspropDownList>
<asp:SqlDataSource ID="SqlProvinces" Runat="server"
SelectCommand="igyw_ProvincesSorted"
ConnectionString="<%$ ConnectionStringsBConnString %>">
<SelectParameters>
<asp:ControlParameter Name="Country" Type="Int32"
ControlID="DropDownListCountries"
PropertyName="SelectedValue"></asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</td>
</tr>
</table>
drop down list displays a list of continents, the second displays a
list of countries and the third displays a list of provinces. All
three drop down lists are fed by data sources that use stored
procedures. The stored procedure for filling the Countries drop down
list uses a parameter for filtering the countries that should fill the
list, and the value for that parameter comes from the value of the
currently selected item in the Continents drop down list.
The provinces control is implemented in a similar way. It has a stored
procedure which takes a parameter to filter which provinces to
display. The value of the parameter comes from the value of the
selected country in the Countries drop down list.
So: The filter for provinces depends on the item selected for a
country. And the filter for countries depends on the item selected as
a continent. My problem is that I can change a continent by selecting
a new one in that drop down list, which in turn updates the list of
items available in the countries drop down list, BUT the provinces
drop down list is not updated to reflect the fact that the countries
list has changed because the continents list changed.
I was hoping that a series of controls which have a chain of
dependencies on each other would be smart enough to update properly,
but that does not appear to be so. Is there anything simple that I am
missing here. Maybe I need to handle an event of some sort and
implement a bit of server-side code to properly update the controls,
but I was hoping not.
The first time I run the page I get these values as the first entries
in the drop down lists:
Continent = Africa, Country = Algeria, Province = Adrar
If i then change the continent to Europe, I get:
Continent = Europe, Country = United Kingdom, Province = Adrar - so
the province totally missed the fact that the country has changed.
Any ideas anyone?
Thanks in advance,
Geoff Taylor
Code is below:
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td
class="InnerInterfaceTheme">
<table width="100%"
cellspacing="0" cellpadding="0" border="0">
<tr><td colspan="8"
height="10"></td></tr>
<tr>
<td nowrap
width="10"> </td>
<td nowrap
width="1">
<asp:Image
ID="Step1" Runat="server" ImageUrl="~/Img/step1.gif" />
</td>
<td
style="position : relative; top : -5px;"
class="FieldsText"> Where:
<aspropDownList ID="DropDownListContinents" Runat="server"
SourceID="SqlContinents"
DataTextField="ContinentName" DataValueField="pkContinentID"
AutoPostBack="True">
</aspropDownList>
<asp:SqlDataSource ID="SqlContinents" Runat="server"
SelectCommand="igyw_ContinentsSorted"
ConnectionString="<%$ ConnectionStringsBConnString %>">
</asp:SqlDataSource> >
<aspropDownList ID="DropDownListCountries" Runat="server"
DataSourceID="SqlCountries"
DataTextField="Country" DataValueField="pkCountryID"
AutoPostBack="True">
</aspropDownList>
<asp:SqlDataSource ID="SqlCountries" Runat="server"
SelectCommand="igyw_CountriesSorted"
ConnectionString="<%$ ConnectionStringsBConnString %>">
<SelectParameters>
<asp:ControlParameter Name="Continent" Type="Int32"
ControlID="DropDownListContinents"
PropertyName="SelectedValue"></asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource> >
<aspropDownList ID="DropDownListProvinces" Runat="server"
DataSourceID="SqlProvinces"
DataTextField="Province" DataValueField="pkProvinceID"
AutoPostBack="True">
</aspropDownList>
<asp:SqlDataSource ID="SqlProvinces" Runat="server"
SelectCommand="igyw_ProvincesSorted"
ConnectionString="<%$ ConnectionStringsBConnString %>">
<SelectParameters>
<asp:ControlParameter Name="Country" Type="Int32"
ControlID="DropDownListCountries"
PropertyName="SelectedValue"></asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</td>
</tr>
</table>