CascadingDropDown taking two parameters...

Posted by WeeShian on Stack Overflow See other posts from Stack Overflow or by WeeShian
Published on 2009-12-30T04:32:27Z Indexed on 2010/05/04 9:38 UTC
Read the original article Hit count: 326

Filed under:
|

I have a page with 3 dropdownlist, 2nd and 3rd dropdownlist are added with CascadingDropDown. 3rd dropdownlist will take parameters from 1st and 2nd dropdownlist. So, in current example for CascadingDropDown i have found from google, they are only passing one parameter to the WebService method. How can pass two parameters to the service method, so that my 3rd dropdownlist will based on the SelectedValue of 1st and 2nd dropdownlist?

<WebMethod()> _
Public Function GetTeams(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
    Dim strConnection As String = ConfigurationManager.ConnectionStrings("nerdlinessConnection").ConnectionString
    Dim sqlConn As SqlConnection = New SqlConnection(strConnection)
    Dim strTeamQuery As String = "SELECT * FROM TEAM WHERE conf_id = @confid"
    Dim cmdFetchTeam As SqlCommand = New SqlCommand(strTeamQuery, sqlConn)

    Dim dtrTeam As SqlDataReader
    Dim kvTeam As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)

    Dim intConfId As Integer

    If Not kvTeam.ContainsKey("Conference") Or Not Int32.TryParse(kvTeam("Conference"), intConfId) Then
        Return Nothing
    End If

    cmdFetchTeam.Parameters.AddWithValue("@confid", intConfId)
    Dim myTeams As New List(Of CascadingDropDownNameValue)

    sqlConn.Open()
    dtrTeam = cmdFetchTeam.ExecuteReader

    While dtrTeam.Read()
        Dim strTeamName As String = dtrTeam("team_name").ToString
        Dim strTeamId As String = dtrTeam("team_id").ToString

        myTeams.Add(New CascadingDropDownNameValue(strTeamName, strTeamId))
    End While

    Return myTeams.ToArray
End Function

This is the sample code i found! As you can see in the code, '@confid' will be passed from 2nd dropdownlist! So, hw do i modify this code to get the selected value from 1st dropdownlist as well??

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about cascadingdropdown