Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have a cascading dropdownlists. When you select an item from the first ddl, the 2nd ddl gets populated with the correct list. The problem is when you select an item from the 2nd ddl, it always shows the first item on the list and it does not populate the 3rd ddl. How can I solve this without ajaxtoolkit?

UPDATE by OP:
here is the code
XML
<form id="Form1" method="post" runat="server">
  <asp:ScriptManager ID="ScriptManager" runat="server" />
    <asp:UpdatePanel ID="Panel1" runat="server" ChildrenAsTriggers="true">
    <ContentTemplate>
        <asp:DropDownList ID="cbCL" runat="server" Width="209px" AutoPostBack="true" OnSelectedIndexChanged="SetShip" ></asp:DropDownList>
        <asp:DropDownList ID="cbShip" runat="server" Width="209px" AutoPostBack="true" OnSelectedIndexChanged="SetPort" ></asp:DropDownList>
        <asp:DropDownList ID="cbPort" runat="server" Width="209px" AutoPostBack="true" ></asp:DropDownList>
        <asp:DropDownList ID="cbMerchant" runat="server" Width="209px" ></asp:DropDownList>
    </ContentTemplate>
    </asp:UpdatePanel>
</form>


SQL
Public Sub SetShip(ByVal sender As Object, ByVal e As System.EventArgs)
         Common.BindShipByCL(cbShip, cbCL.SelectedItem.Value, Date.Today)
  End Sub
  Public Sub SetPort(ByVal sender As Object, ByVal e As System.EventArgs)
     Common.BindPortByShip(cbPort, cbShip.SelectedItem.Value, Date.Today)   
  End Sub


Thanks,
Martin
Posted
Updated 15-Sep-10 8:32am
v2
Comments
AspDotNetDev 14-Sep-10 16:56pm    
Show us what code you are using. It's obvious your code is wrong, so seeing it would help us help you to fix it.

If you see the code, you will find that the cascading dropdowns are present in a single update panel and thus all will get refreshed based on postback of any one.

Surely, before picking up the second dropdown value for populating 3rd one is lost and thus nothing happens.
Just use DEBUGGER and that should tell you how the execution is happening. Further, if you have missed using Page.IsPostback & ScriptManager.IsInAsyncPostBack page properties then do apply them such that the dropdowns are not getting freshly populated before the onchange event is fired.
 
Share this answer
 
There are various ways to get Cascading dropdown. Earlier it was Server side, then traditional AJAX==XMLHttpRequest. Now, we can use Update panel or PageMethod for it.

Ajaxtoolkit provide a cascading control. One can opt not to use it and have any one of the above.

Surely the selections should work. Use XMLHttpRequest or UpdatePanel or PageMethod.
 
Share this answer
 
Comments
Martin_ 15-Sep-10 14:17pm    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
Dalek Dave 15-Sep-10 15:53pm    
Good Answer
Hi,
If u using cascading dropdown list, U must using ajax tool kit.
 
Share this answer
 
Comments
Sandeep Mewara 15-Sep-10 2:37am    
Not necessarily!

There are various ways to get Cascading dropdown. Earlier it was Server side, then traditional AJAX==XMLHttpRequest. Now, we can use Update panel or PageMethod for it.

Ajaxtoolkit provide a cascading control. One can opt not to use it and have any one of the above.
Martin_ 15-Sep-10 11:21am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
Sergey Alexandrovich Kryukov 14-Aug-11 2:24am    
That brings the question: why would you accept this wrong answer?
--SA
William Winner 15-Sep-10 13:34pm    
Reason for my vote of 1
as has been said, there are many ways to do it without the ajax toolkit.
Manfred Rudolf Bihy 12-Aug-11 11:12am    
No text speak please! Read the FAQ!
I am using Page.IsPostback to load the first ddl. But I am not using IsInAsynchPostBack. I've never used it, I'm not sure how to use it.

VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If (Not Page.IsPostBack) Then
        Common.BindCruiseLine(cbCL)
    End If
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900