Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Single associated record in cascading dropdown

Author  Topic 

mattlightbourn
Starting Member

37 Posts

Posted - 2009-12-11 : 12:47:12
Hi,

I have two dropdowns driven from an SQL data source.

The first one does JobCategory and posts back

The second one lists JobTypes based upon JobTypes that have the JobCategoryID as above.

This JobTypes are limited correctly in the list but, it shows the first possible choice in the drop down automatically but, doesn't let me select it unless I select something else and then select the first one in the list again.

My question is two really:

1. How can I make it so that dropdown2 is blank and left me choose from the list so that it pasts back my selection?

OR

2. How can I get it to identify that by displaying the first choice of the list, it is also selected until changed by user?

Either one of those questions will do but, I think the answer to question 1 would be more benefitial.

Thank you for your input.

Kind Regards

Matt

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-11 : 13:52:34
why dont add a default option like 'please select' which will be default in dropdown2
Go to Top of Page

mattlightbourn
Starting Member

37 Posts

Posted - 2009-12-12 : 12:08:35
That doesn't work, the "default" when choose data source in the "where" section does not work.


</asp:DropDownList>
<asp:SqlDataSource ID="JobTypes" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [JobTypeID], [JobType], [JobCategory] FROM [JobTypes] WHERE ([JobCategory] = @JobCategory)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="JobCategory"
PropertyName="SelectedValue" Type="Int32" DefaultValue="48" />
</SelectParameters>
</asp:SqlDataSource>
<asp:TextBox ID="TextBox1" runat="server" Height="16px" Width="201px"></asp:TextBox>
<asp:DropDownList ID="DropDownList5" runat="server" AutoPostBack="True"
DataSourceID="BrandInfo" DataTextField="BrandGuideName"
DataValueField="BrandGuidelinesID" Height="23px" Width="300px">
</asp:DropDownList>


The drop down is dynamic and, I've had to select a "JobCategory" for the new entry for JobType as 1 - since this is the first one selected when going to that page.

However, it still selects the first in list and ignore the properties of default="48". which is the ID of "Please Select".

Plus, Want it to be "Please Select" for any one of the options in the first JobCategories drop down.

Thanks for your help thus far, any other idea?

Thanks
Go to Top of Page

mattlightbourn
Starting Member

37 Posts

Posted - 2009-12-13 : 09:47:43
Could anyone else please let me know how you would ensure that a dynamic drop-down does not have a value in it until you actually select one? It shows the first related option but doesn't act as if it's selected it. You have to select something else then select the first one again for it to work, I can't be the first person to have this issue.

Thanks
Go to Top of Page

mattlightbourn
Starting Member

37 Posts

Posted - 2009-12-14 : 10:29:37
Do I need to change something here:


<SelectParameters>
<asp:ControlParameter ControlID="StudioContact" Name="UserID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>


to make it so that the default selected value is "Please select"?

Thanks
Go to Top of Page

mattlightbourn
Starting Member

37 Posts

Posted - 2009-12-16 : 06:04:43
Hi,

Have I posted my question in the wrong forum? I have had no reply and think that, as my post is the last one and has been for days, it mustn't be getting looked at?

Thanks
Go to Top of Page
   

- Advertisement -