Hi everyone,
I have a web page that contains a gridview, which is a grid for the days in a month (one row per day). In each row, there I have 2 CascadingDropDowns (one parent, one child, for a total of 4 dropdown lists). Here is what it looks like:

The Type dropdown is the parent, the Reason dropdown is the child - the reasons change based on the type_code selected. Easy.
My problem is the page is loaded, the CDD's take an additional 8-10 seconds to populate (ie: displays the LoadingText for this additional 8-10 seconds).
Originally, in the webservice that populates the CCDs, I was hitting the database and thought the problem was too many calls to the DB, so I cached the values in a datatable and load them from the session (see my web service code below). However, the load time is exaclty the same.
Is there a way I can optimize my CascadingDropDowns? Unfortunately, this load time will not be acceptable to my client, and I have hit a wall in solving this.
Many thanks!!!! Below is the code for the webservice that populates the dropdowns; if you need to see more code, just let me know.
Imports System.Collections.Specialized
Imports AjaxControlToolkit
Imports System.Data
Imports System.Data.SqlClient
Imports System.Globalization
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.<System.Web.Script.Services.ScriptService()> _<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _<ToolboxItem(False)> _
Public Class wsReasons
Inherits System.Web.Services.WebService
'Uncomment the following line if using designed components
'InitializeComponent();
Public Sub New()
End Sub
'Retrieves a list of Types<WebMethod(EnableSession:=True)> _
Public Function GetTypes(ByVal knownCategoryValues As String, ByVal category As String, ByVal contextKey As String) As CascadingDropDownNameValue()
Dim values As New List(Of CascadingDropDownNameValue)()
Dim type_desc As String = ""
Dim type_Code As String = ""
Dim lang As String = Session("Lang")
Dim workTypes_Datatable As DataTable = Session("Types_DataTable")
For Each dr As DataRow In workTypes_Datatable.Rows
If lang = "F" Then
type_desc = Trim(dr("fr").ToString)
Else
type_desc = Trim(dr("en").ToString)
End If
type_Code = Trim(dr("Type_Code").ToString)
If dr("Type_Code") = contextKey Then
values.Add(New CascadingDropDownNameValue(type_desc, type_Code, True))
Else
values.Add(New CascadingDropDownNameValue(type_desc, type_Code, False))
End If
Next
Return values.ToArray()
End Function
'Retrieves a list of Reason Codes to the requested Type Code<WebMethod(EnableSession:=True)> _
Public Function GetReasonsForType(ByVal knownCategoryValues As String, ByVal category As String, ByVal contextKey As String) As CascadingDropDownNameValue()
Dim lang As String = Session("Lang")
Dim intTypeCode As Integer
Dim kvReason As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
If Not kvReason.ContainsKey("Type_Code") Or Not Int32.TryParse(kvReason("Type_Code"), intTypeCode) Then
Return Nothing
End If
Dim myReasons As New List(Of CascadingDropDownNameValue)
Dim strReasonDesc As String = ""
Dim strReasonCode As String = ""
Dim reasons_Datatable As DataTable = Session("Reason_DataTable")
Dim filteredResults As DataRow() = reasons_Datatable.Select("Type_Code = " & intTypeCode)
For Each row As DataRow In filteredResults
If lang = "F" Then
strReasonDesc = Trim(row("fr").ToString)
Else
strReasonDesc = Trim(row("en").ToString)
End If
strReasonCode = Trim(row("Reason_Code").ToString)
If Trim(row("Reason_Code")) = contextKey Then
myReasons.Add(New CascadingDropDownNameValue(strReasonDesc, strReasonCode, True))
Else
myReasons.Add(New CascadingDropDownNameValue(strReasonDesc, strReasonCode, False))
End If
Next
Return myReasons.ToArray
End Function
End Class