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

How to Double cascade my dropdownlist (AJAX ControlToolkit - Cascading DropdownList)

$
0
0

Hey there,

I hope this is the right forum for it, I am in the process of updating an existing VB.Net web application.

My user control uses the AJAX ControlToolkit to pre populate the next dropdownlist based on the previous item selected in another dropdown.

I was hoping someone could enlighten me on how to cascade all the way down the dropdownlist chain.  (some projects only have one phase and one task)

EXAMPLE:  ddlProject -> ddlProjectPhase -> ddlProjectPhaseTask

So if I select a Project and it only has 1 phase, then cascade to task and if it only has one task then select that task.

Currently i have to Select my project (which populates 1 phase), then i have to select that phase (which populates 1 task), then i have to select that 1 task...

I want it to be smart enough to only make manual selections if there are more the 1 value to choose from, other wise just pre-populate all dropdowns with that 1 lonesome value in the list.

My Phase Code:

<WebMethod()> _
    Public Function GetParentAccountProjectTasks(ByVal knownCategoryValues As String, ByVal category As String) As AjaxControlToolkit.CascadingDropDownNameValue()

        Dim Value As String = Replace(Replace(knownCategoryValues, ";", ""), "undefined:", "")
        Dim CategoryValue() As String = Split(category, ",")

        'this get the project id
        Value = Value.Substring(Value.IndexOf(".") + 1)

        Dim objRow As TimeLiveDataSet.AccountProjectTaskRow
        Dim objAccountProjectTaskBLL As New AccountProjectTaskBLL

        Dim objTable As TimeLiveDataSet.AccountProjectTaskDataTable

        objTable = objAccountProjectTaskBLL.GetParentAccountProjectTasksByAccountProjectId(Value, CategoryValue(0))
        Dim values As New Generic.List(Of AjaxControlToolkit.CascadingDropDownNameValue)

        For Each objRow In objTable.Rows
            values.Add(New AjaxControlToolkit.CascadingDropDownNameValue(objRow.TaskName, objRow.AccountProjectTaskId))
        Next

        Me.Context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache)

        Return values.ToArray

    End Function

My Task Code:

<WebMethod()> _
    Public Function GetParentAccountProjectTasks(ByVal knownCategoryValues As String, ByVal category As String) As AjaxControlToolkit.CascadingDropDownNameValue()

        Dim Value As String = Replace(Replace(knownCategoryValues, ";", ""), "undefined:", "")
        Dim CategoryValue() As String = Split(category, ",")

        'this get the project id
        Value = Value.Substring(Value.IndexOf(".") + 1)

        Dim objRow As TimeLiveDataSet.AccountProjectTaskRow
        Dim objAccountProjectTaskBLL As New AccountProjectTaskBLL

        Dim objTable As TimeLiveDataSet.AccountProjectTaskDataTable

        objTable = objAccountProjectTaskBLL.GetParentAccountProjectTasksByAccountProjectId(Value, CategoryValue(0))
        Dim values As New Generic.List(Of AjaxControlToolkit.CascadingDropDownNameValue)

        For Each objRow In objTable.Rows
            values.Add(New AjaxControlToolkit.CascadingDropDownNameValue(objRow.TaskName, objRow.AccountProjectTaskId))
        Next

        Me.Context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache)

        Return values.ToArray

    End Function

Any help would be greatly appreciated !!


Thanks. sc


Viewing all articles
Browse latest Browse all 5678

Trending Articles



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