Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > ASP.NET 2.0 Drop Down List controls

Reply
Thread Tools

ASP.NET 2.0 Drop Down List controls

 
 
Geoff Taylor
Guest
Posts: n/a
 
      07-18-2004
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">&nbsp;</td>
<td nowrap
width="1">
<asp:Image
ID="Step1" Runat="server" ImageUrl="~/Img/step1.gif" />
</td>

<td
style="position : relative; top : -5px;"
class="FieldsText">&nbsp;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>&nbsp;&gt;&nbsp;

<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>&nbsp;&gt;&nbsp;

<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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
Multiple select drop down poplulating sub drop down scott@dettcom.com Javascript 3 11-09-2006 07:50 PM
Auto Drop down a Drop Down List xxbmichae1@supergambler.com Javascript 5 11-23-2005 01:35 AM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM



Advertisments