Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dropdownlist autopostback problem

Reply
Thread Tools

dropdownlist autopostback problem

 
 
andy
Guest
Posts: n/a
 
      03-28-2007
Hi,

I have a form uses several dropdownlists to narrow a set of criteria.
( This is in turn used to control what is shown on a gridview. )
With each, the user selects an entry and then the next dropdownlist
uses that control's selected value to drive what it shows.
They're all set to autopostback.
Everything works fine except where one of the levels only has one
entry.
This seems to mess up the next level down and you see the wrong
results.
If you fiddle around and select another branch of the tree has more
than one entry in a list then go back it finds the data.
So all the control sources etc are OK.

Any ideas on a work round?

Code snippet:

<fieldset style="width:200px;padding:3px">
<legend>Business Level</legend>
<h2>Conpany</h2>
<aspropDownList ID="ddlCompanies" width="99%" runat="server"
DataSourceID="sdsCompanies" DataTextField="Company"
DataValueField="Company_Id" AutoPostBack="True"
ToolTip="Company">
</aspropDownList>
<h2>Business Stream</h2>
<aspropDownList ID="ddlBusiness_Streams" width="99%"
runat="server" DataSourceID="sdsBusiness_Streams"
DataTextField="Business_Stream"
DataValueField="Business_Stream_Id" AutoPostBack="True"
ToolTip="Business Stream">
</aspropDownList>
<h2>Operating Group</h2>
<aspropDownList ID="ddlOperating_Groups" width="99%"
runat="server" AutoPostBack="True" DataSourceID="sdsOperating_Groups"
DataTextField="Operating_Group"
DataValueField="Operating_Group_Id" ToolTip="Operating Group">
</aspropDownList>
<h2>Business Unit</h2>
<aspropDownList ID="ddlBusiness_Units" width="99%"
runat="server" AutoPostBack="True" DataSourceID="sdsBusiness_Unit"
DataTextField="Business_Unit"
DataValueField="Business_Unit_Id" ToolTip="Business Unit" >
</aspropDownList>
<h2>Division</h2>
<aspropDownList ID="ddlDivisions" width="99%"
runat="server" AutoPostBack="True" DataSourceID="sdsDivisions"
DataTextField="Division" DataValueField="Div_No"
ToolTip="Division">
</aspropDownList>
</fieldset>

<asp:SqlDataSource ID="sdsCompanies" runat="server"
ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand="SELECT [Company_Id], [Company] FROM
[Companies] ORDER BY [Company]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsBusiness_Streams" runat="server"
ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand="SELECT [Business_Stream_Id],
[Business_Stream] FROM [Business_Streams] WHERE ([Company_Id] =
@Company_Id) ORDER BY [Business_Stream]">
<SelectParameters>
<asp:ControlParameter ControlID="ddlCompanies"
DefaultValue="0" Name="Company_Id"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsOperating_Groups" runat="server"
ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand="SELECT [Operating_Group_Id],
[Operating_Group] FROM [Operating_Groups] WHERE ([Business_Stream_Id]
= @Business_Stream_Id)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlBusiness_Streams"
DefaultValue="0" Name="Business_Stream_Id"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsBusiness_Unit" runat="server"
ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand="SELECT [Business_Unit_Id], [Business_Unit]
FROM [Business_Units] WHERE ([Operating_Group_Id] =
@Operating_Group_Id)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlOperating_Groups"
DefaultValue="0" Name="Operating_Group_Id"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsDivisions" runat="server"
ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand="SELECT [Div_No], [Division] FROM
[Divisions] WHERE ([Business_Unit_Id] = @Business_Unit_Id)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlBusiness_Units"
DefaultValue="0" Name="Business_Unit_Id"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

 
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
Problem with AutoPostback and DropDownlist / Multipage Dennis George ASP .Net Web Controls 0 06-01-2005 06:27 AM
DropDownList (with AutoPostBack) in a DataGrid Jaleel Syed via .NET 247 ASP .Net 0 04-23-2004 04:56 AM
Re: DropDownlist OnSelectionChanged and AutoPostback = False S. Justin Gengo ASP .Net 0 08-15-2003 06:27 PM
Re: DropDownlist OnSelectionChanged and AutoPostback = False George Durzi ASP .Net 0 08-15-2003 03:10 PM
DropDownList and AutoPostback -- default item Null ASP .Net 1 08-05-2003 03:28 PM



Advertisments