Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

Populate dropdownlist with secondary

I have a dropdownlist that chooses a description of a major category. The code works by sequence, If I choose a major sequence  i want to populate the secondary dropdownlist with all the minor categorys. Not to sure how to make this happen.
If ddCatsMinor.SelectedIndex + 1 = ddCatsMinor.Items.Count Then
                EndingValue = 99999999
            Else
                EndingValue = ddCatsMinor.Items(ddCatsMinor.SelectedIndex + 1).Value
            End If
            Response.Redirect("SRP.aspx?i=" & Format(Val(ddCatsMinor.SelectedValue), "00000000") & "2" & Format(EndingValue, "00000000"))
        End If
 
 
''########################################################
Private Sub SetupOBItems()
 
 
        Dim cmd As SqlCommand
        Dim prm As SqlParameter
 
        cmd = New SqlCommand("spA1SGetItemsForOBHeader", conn)
        cmd.CommandType = CommandType.StoredProcedure
 
        prm = New SqlParameter("@BegSeq", SqlDbType.Int)
        prm.Value = Mid(Request.QueryString("i"), 1, 8)
        cmd.Parameters.Add(prm)
 
        prm = New SqlParameter("@EndSeq", SqlDbType.Int)
        prm.Value = Val(Mid(Request.QueryString("i"), 10, 8)) - 1
        cmd.Parameters.Add(prm)
 
        Dim oRDR As SqlDataReader
        cmd.CommandTimeout = 120 'Number of seconds to wait for a response.
 
        conn.Open()
        oRDR = cmd.ExecuteReader(CommandBehavior.Default)
 
        While oRDR.Read
            cIdx += 1
            ReDim Preserve Items(cIdx)
            Items(cIdx) = oRDR("Product")
        End While
 
        'Clean Up
        If (Not oRDR Is Nothing) Then
            If (oRDR.IsClosed) Then
                oRDR.Close()
            End If
        End If
        If (Not conn Is Nothing) Then
            If conn.State <> ConnectionState.Closed Then conn.Close()
            conn.Dispose()
        End If
        If Not cmd Is Nothing Then cmd.Dispose()
 
    End Sub
 
 
''"###############################################
Private Sub LoadOBCats()
        Dim ar As ListItem()
        Dim ku As Long = 0
 
 
        Dim cmd As SqlCommand
        Dim prm As SqlParameter
 
        cmd = New SqlCommand("spA1SGetOBHeaders", conn)
        cmd.CommandType = CommandType.StoredProcedure
 
        Dim oRDR As SqlDataReader
        cmd.CommandTimeout = 120 'Number of seconds to wait for a response.
 
        conn.Open()
        oRDR = cmd.ExecuteReader(CommandBehavior.Default)
 
        While oRDR.Read
            ddCats.Items.Add(oRDR("Description"))
            ddCats.Items(ddCats.Items.Count - 1).Value = oRDR("OrderBookSequence")
 
        End While
        For Each li As ListItem In ddCats.Items
            ReDim Preserve ar(ku)
            ar(ku) = li
            ku += 1
        Next
        Dim ar1 As Array = ar
 
        ar1.Sort(ar1, New ListItemComparer)
        ddCats.Items.Clear()
        'Add an item that will appear as the default selected item in the dropdown list
        ddCats.Items.Add(New ListItem("Select one", "Select one"))
        ddCats.Items.AddRange(ar1)
        'Clean Up
        If (Not oRDR Is Nothing) Then
            If Not (oRDR.IsClosed) Then
                oRDR.Close()
            End If
        End If
        oRDR = Nothing
        If (Not conn Is Nothing) Then
            If conn.State <> ConnectionState.Closed Then conn.Close()
            conn.Dispose()
        End If
        If Not cmd Is Nothing Then cmd.Dispose()
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ppittle
ppittle
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seven price

ASKER

I have to look at this later. The firewall here is blocking the video site.