Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Cascading dropdownlists in Accordion and tabs not working

$
0
0

I have created a JQuery accordion of which I’m trying to implement a Cascading DropDownList (4 DropDowns).

The initial dropdown is bound to a stored procedure in the Page_Load event. This populates and works fine.

The other 3 dropdowns are also connected through stored procedures and are placed in their own SelectedIndexChanged events. The first dropdownlist (Page_Load event) also has a separate SelectedIndexChanged event. None of these seem to actually be firing.

When I execute the stored procedures in MSSQL Management Studio they all output the correct result. However one thing I need to mention is the ID for each of the stored procedures is a varchar.

This is from an old, non-relational, single distinct table in a database and not how I would have done it. But it holds too much data to correct.  

I've cut the code down as there far too much for these pages

<asp:ScriptManager ID="AccordionScriptManager" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpAccordionSearch" runat="server" ChildrenAsTriggers="false"
        UpdateMode="Conditional"><ContentTemplate><div id="tabs-4"><div class="Table"><div class="Row"><div class="Cell">
                                                One:</div><div class="Cell"><asp:DropDownList ID="ddl1l" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl1_SelectedIndexChanged" /></div></div><div class="Row"><div class="Cell">
                                                Two:</div><div class="Cell"><asp:DropDownList ID="ddl2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl2_SelectedIndexChanged" /></asp:DropDownList></div></div><div class="Row"><div class="Cell">
                                                Three:</div><div class="Cell"><asp:DropDownList ID="ddl3" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl3_SelectedIndexChanged"  /></div></div><div class="Row"><div class="Cell">
                                                Four:</div><div class="Cell"><asp:DropDownList ID="ddl4" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl4_SelectedIndexChanged" /></div></div><div class="Row"><div class="Cell"></div><div class="Cell"><div class="Row"><div class="Cell"><asp:Button runat="server" ID="btn_Reset " Text="Reset" OnClientClick="this.form.reset();return false;" /></div><div class="Cell"><asp:Button ID="btnAccordion" runat="server" Text="Search" OnClick="btn_Click" /></div></div></div></div></div></div></div></div></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="btnAccordion" EventName="click" /></Triggers></asp:UpdatePanel>
Protected Sub ddl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

        Try
            Using con As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConn").ConnectionString)
                Using cmd As New SqlCommand()
                    cmd.CommandType = CommandType.StoredProcedure
                    cmd.CommandText = "sp_1"
                    cmd.Parameters.AddWithValue("@one", ddl1.SelectedItem.ToString())
                    cmd.Connection = con
                    con.Open()
                    Dim da As New SqlDataAdapter(cmd)
                    Dim dt As New DataTable()
                    da.Fill(dt)
                    ddl2.DataSource = dt
                    ddl2.DataValueField = "Code2"
                    ddl2.DataTextField = "Name2"
                    ddl2.DataBind()
                    con.Close()

ddl2.Items.Insert(0, New ListItem("Please select Name2", "0"))

                    
                    ddl3.Items.Clear()
                    ddl3.Items.Insert(0, New ListItem("Please select Name3", "0"))
                End Using
            End Using
        Catch
        End Try


    End Sub

    Protected Sub ddl2_SelectedIndexChanged(sender As Object, e As EventArgs)

        Try
            Using con As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConn").ConnectionString)
                Using cmd As New SqlCommand()
                    cmd.CommandType = CommandType.StoredProcedure
                    cmd.CommandText = "sp_2"
                    cmd.Parameters.AddWithValue("@two", ddl2.SelectedValue.ToString())
                    cmd.Connection = con
                    con.Open()
                    Dim da As New SqlDataAdapter(cmd)
                    Dim dt As New DataTable()
                    da.Fill(dt)


                    ddl3.DataSource = dt
                    ddl3.DataTextField = "Name3"
                    ddl3.DataValueField = "Code3"
                    ddl3.DataBind()
                    con.Close()
                    ddl3.Items.Insert(0, New ListItem("--Select--", "0"))

                    If ddl3.SelectedValue = "0" Then
                        Ddl3.Items.Clear()
                        Ddl3.Items.Insert(0, New ListItem("--Select--", "0"))
                    End If


                End Using
            End Using
        Catch
        End Try


    End Sub

    Protected Sub ddl3_SelectedIndexChanged(sender As Object, e As EventArgs)


        Try
            Using con As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConn").ConnectionString)
                con.Open()
                Using cmd As New SqlCommand()

                    cmd.CommandType = CommandType.StoredProcedure
                    cmd.CommandText = "sp_3"
                    cmd.Parameters.AddWithValue("@three", ddl3.SelectedItem.Value)
                    cmd.Connection = con

                    Dim da As New SqlDataAdapter(cmd)
                    Dim ds As New DataSet()
                    da.Fill(ds)

                    con.Close()
                    ddl4.DataSource = ds
                    ddl4.DataTextField = "Name4"
                    ddl4.DataValueField = "code4"
                    ddl4.DataBind()


                End Using
            End Using
        Catch
        End Try
    End Sub



Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>