• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5464
  • Last Modified:

Method Error 500 in AJAX cascading dropdownlist

So, I'm getting this method error 500. I can see lots of other people have experienced this but whatever fixes they have come up with don't work or maybe i don't understand. The code i use is below. Any ideas?

The query seems ok and when i execute it, it returns 1 value, so presumably that is fine.

Thanks, Aiden
// In my default.aspx page
<cc1:CascadingDropDown  ID="CascadingDropDown1" 
                                PromptText="Please select the Quarter"
                                LoadingText="Please wait..."
<table style="z-index: 112; left: 245px; position: absolute; top: 101px">
                <td style="width: 124px; height: 21px; text-align: right">Quarter:</td>
                <td style="width: 11px; height: 21px"></td>
                <td style="width: 170px; height: 21px">
                    <asp:DropDownList ID="ddlQuarter" runat="server" Width="165px"/>
                <td style="width: 124px; text-align: right">Customer:</td>
                <td style="width: 11px"></td>
                <td style="width: 170px">
                    <asp:DropDownList ID="ddlCustomer" runat="server" Width="165px"/>
                <td style="width: 124px; text-align: right">Region:</td>
                <td style="width: 11px"></td>
                <td style="width: 170px">
                    <asp:DropDownList ID="ddlRegion" runat="server" Width="165px"/>
// In my webservice.asmx page
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports AjaxControlToolkit
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class CSATSearchService
   Inherits System.Web.Services.WebService
   <WebMethod()> _
   Public Function GetCSATData(ByVal knowncategoryvalues As String, ByVal Category As String) As CascadingDropDownNameValue()
      'took out shared
      Dim quarterAdapter As New CSATSearchTableAdapters.CSAT_DataTableAdapter
      Dim quarterValues As New List(Of CascadingDropDownNameValue)()
      For Each row As DataRow In quarterAdapter.GetQuarter
         quarterValues.Add(New CascadingDropDownNameValue(row("Quarter").ToString, row("Customer Name").ToString))
      Return quarterValues.ToArray
   End Function
End Class
// my xsd page. Query appears to run fine and only returns 1 value so can't be an overflow problem
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="CSATSearch" targetNamespace="http://tempuri.org/CSATSearch.xsd" xmlns:mstns="http://tempuri.org/CSATSearch.xsd" xmlns="http://tempuri.org/CSATSearch.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
    <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
      <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
          <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="CSAT DatabaseConnectionString" ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly" Name="CSAT DatabaseConnectionString (Web.config)" PropertyReference="AppConfig.System.Configuration.ConfigurationManager.0.ConnectionStrings.CSAT DatabaseConnectionString.ConnectionString" Provider="System.Data.OleDb">
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="CSAT DataTableAdapter" GeneratorDataComponentClassName="CSAT_DataTableAdapter" Name="CSAT Data" UserDataComponentName="CSAT DataTableAdapter">
              <DbSource ConnectionRef="CSAT DatabaseConnectionString (Web.config)" DbObjectName="CSAT Data" DbObjectType="Table" GenerateMethods="Get" GenerateShortCommands="False" GeneratorGetMethodName="GetQuarter" GetMethodModifier="Public" GetMethodName="GetQuarter" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="False" UserGetMethodName="GetQuarter" UserSourceName="Fill">
                  <DbCommand CommandType="Text" ModifiedByUser="True">
                    <CommandText>SELECT DISTINCT Quarter
FROM         [CSAT Data]</CommandText>
              <Mapping SourceColumn="Quarter" DataSetColumn="Quarter" />
  <xs:element name="CSATSearch" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="CSATSearch" msprop:Generator_DataSetName="CSATSearch">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="CSAT_x0020_Data" msprop:Generator_UserTableName="CSAT Data" msprop:Generator_RowDeletedName="CSAT_DataRowDeleted" msprop:Generator_TableClassName="CSAT_DataDataTable" msprop:Generator_RowChangedName="CSAT_DataRowChanged" msprop:Generator_RowClassName="CSAT_DataRow" msprop:Generator_RowChangingName="CSAT_DataRowChanging" msprop:Generator_RowEvArgName="CSAT_DataRowChangeEvent" msprop:Generator_RowEvHandlerName="CSAT_DataRowChangeEventHandler" msprop:Generator_TablePropName="CSAT_Data" msprop:Generator_TableVarName="tableCSAT_Data" msprop:Generator_RowDeletingName="CSAT_DataRowDeleting">
              <xs:element name="Quarter" msprop:Generator_UserColumnName="Quarter" msprop:Generator_ColumnPropNameInRow="Quarter" msprop:Generator_ColumnVarNameInTable="columnQuarter" msprop:Generator_ColumnPropNameInTable="QuarterColumn" minOccurs="0">
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="255" />

Open in new window

  • 5
  • 4
2 Solutions
Muhammad Ousama GhazaliSolution Analyst & ArchitectCommented:
I think you need to take equal number of CascadingDropDown controls as the number of DropDownList controls involved. Check the attached zip file which contains the official sample of CDD (I could not attach the file due to EE limitation, so pasting the file in code snippet):

<%@ Page
    Title="CascadingDropDown Sample"
    Theme="SampleSiteTheme" %>
<%@ Register
    TagPrefix="ajaxToolkit" %>
<asp:Content ContentPlaceHolderID="SampleContent" Runat="Server">
    <ajaxToolkit:ToolkitScriptManager EnablePartialRendering="true" runat="server" ID="ScriptManager1" />
    <div class="demoarea">
        <div class="demoheading">CascadingDropDown Demonstration</div>
                <td><asp:DropDownList ID="DropDownList1" runat="server" Width="170" /></td>
                <td><asp:DropDownList ID="DropDownList2" runat="server" Width="170" /></td>
                <td><asp:DropDownList ID="DropDownList3" runat="server" Width="170" AutoPostBack="true"
                    OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" /></td>
        <br />
        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1"
            Category="Make"  PromptText="Please select a make"  LoadingText="[Loading makes...]"
            ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents" />
        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DropDownList2"
            Category="Model" PromptText="Please select a model" LoadingText="[Loading models...]"
            ServiceMethod="GetDropDownContentsPageMethod" ParentControlID="DropDownList1" />
        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="DropDownList3"
            Category="Color" PromptText="Please select a color" LoadingText="[Loading colors...]"
            ServicePath="~/CascadingDropDown/CarsService.asmx" ServiceMethod="GetDropDownContents"
            ParentControlID="DropDownList2" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="inline">
                <asp:Label ID="Label1" runat="server" Text="[No response provided yet]" />
                <asp:AsyncPostBackTrigger ControlID="DropDownList3" EventName="SelectedIndexChanged" />
    <div class="demobottom"></div>
    <asp:Panel ID="Description_HeaderPanel" runat="server" style="cursor: pointer;">
        <div class="heading">
            <asp:ImageButton ID="Description_ToggleImage" runat="server" ImageUrl="~/images/collapse.jpg" AlternateText="collapse" />
            CascadingDropDown Description
    <asp:Panel id="Description_ContentPanel" runat="server" style="overflow:hidden;">
            CascadingDropDown is an ASP.NET AJAX extender that can be attached to an ASP.NET DropDownList
            control to get automatic population of a set of DropDownList controls.  Each time the selection
            of one the DropDownList controls changes, the CascadingDropDown makes a call to a specified web
            service to retrieve the list of values for the next DropDownList in the set.
        <br />
            CascadingDropDown enables a common scenario in which the contents of one list depends on the
            selection of another list and does so without having to embed the entire data set in the page or
            transfer it to the client at all.  All the logic about the contents of the set of DropDownList
            controls lives on the server in a web service.  This web service can use any suitable method for
            storing and looking up the relevant data.  The sample web service used here reads the data set
            from a simple hierarchical XML data file.  The sample data file shows that the DropDownList items
            can have distinct names and value (values are optional in the sample).  There is also a walkthrough
            showing how to use a <a href="../Walkthrough/CCDWithDB.aspx">CascadingDropDown with a database</a>.
    <asp:Panel ID="Properties_HeaderPanel" runat="server" style="cursor: pointer;">
        <div class="heading">
            <asp:ImageButton ID="Properties_ToggleImage" runat="server" ImageUrl="~/images/expand.jpg" AlternateText="expand"   />
            CascadingDropDown Properties
    <asp:Panel id="Properties_ContentPanel" runat="server" style="overflow:hidden;" Height="0px">
            The control above is initialized with this code. The <em>italic</em> properties are optional:
<pre>&lt;ajaxToolkit:CascadingDropDown ID="CDD1" runat="server"
    <em>PromptText</em>="Please select a model"
    <em>LoadingText</em>="[Loading models...]"
    <em>SelectedValue</em>="SomeValue" /&gt;</pre>
            <li><strong>TargetControlID</strong> - The ID of the DropDownList to populate.</li>
            <li><strong>Category</strong> - The name of the category this DropDownList represents.</li>
            <li><strong>PromptText</strong> - Optional text to display before the user has selected a value from the DropDownList.</li>
            <li><strong>PromptValue</strong> - Optional value set when PromptText is displayed.</li>
            <li><strong>EmptyText</strong> - Optional text to display when the DropDownList has no data to display.</li>
            <li><strong>EmptyValue</strong> - Optional value set when EmptyText is displayed.</li>
            <li><strong>LoadingText</strong> - Optional text to display while the data for the DropDownList
                is being loaded.</li>
            <li><strong>ServicePath</strong> - Path to a web service that returns the data used to populate
                the DropDownList. This property should be left null if ServiceMethod refers to a page method.
                The web service should be decorated with the System.Web.Script.Services.ScriptService
            <li><strong>ServiceMethod</strong> - Web service method that returns the data used to populate
                the DropDownList.  The signature of this method must match the following:
public CascadingDropDownNameValue[] GetDropDownContents(
       string knownCategoryValues, string category) { ... }</pre>
                Note that you can replace "GetDropDownContents" with a naming of your choice, but the return
                type and parameter name and type must exactly match, including case.</li>
            <li><strong>ContextKey</strong> - User/page specific context provided to an optional overload of the
                web method described by ServiceMethod/ServicePath.  If the context key is used, it should have the
                same signature with an additional parameter named contextKey of type string:
public CascadingDropDownNameValue[] GetDropDownContents(
       string knownCategoryValues, string category, string contextKey) { ... }</pre>
                Note that you can replace "GetDropDownContents" with a name of your choice, but the return type
                and parameter name and type must exactly match, including case.</li>
            <li><strong>UseContextKey</strong> - Whether or not the ContextKey property should be used.  This
                will be automatically enabled if the ContextKey property is ever set (on either the client or
                the server).  If the context key is used, it should have the same signature with an additional
                parameter named contextKey of type string (as described above).</li>
            <li><strong>ParentControlID</strong> - Optional ID of the parent DropDownList that controls the
                contents of this DropDownList.</li>
            <li><strong>SelectedValue</strong> - Optional value to select by default.  This needs to exactly
                match the string representation of a value in the DropDownList.</li>
    <ajaxToolkit:CollapsiblePanelExtender ID="cpeDescription" runat="Server" 
        ImageControlID="Description_ToggleImage" />
    <ajaxToolkit:CollapsiblePanelExtender ID="cpeProperties" runat="Server" 
        ImageControlID="Properties_ToggleImage" />

Open in new window

AidenAAuthor Commented:
why would you need the same number of cascading dropdown lists? I'm not sure that makes sense... i could have many dropdownlists on my page that have nothing to do with the cascading dropdownlists so having to have the same number of cascading dropdown lists i'm not sure makes sense?

Plus, i have just been following the AJAX video and trying to adapt my scenario. The author only dropped one cascadingdropdown control onto his page to begin with... then he runs his code and it is fine. Yeah i just checked again... he definitely doesn't add his second cascading dropdown list control until after he has fully implemented the first cascading dropdownlist

i don't think that can be the problem?
Muhammad Ousama GhazaliSolution Analyst & ArchitectCommented:
As per the sample, the second DDL need to know the parent DDL so that it could appropriately clear/update the list-contents based upon the change in the first DDL.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

AidenAAuthor Commented:
sorry, i don't understand. I haven't gotten that far yet. If you look at the AJAX video on cascading dropdownlists, the author also does not implement the 2nd cascading dropdownlist... you see what I'm saying? He does NOT implement the second dropdownlist, does not even have a second one on his page. He puts it on AFTER he FULLY implements the first dropdownlist. The 2nd one does do anything, it is not attached to anything etc etc...
Muhammad Ousama GhazaliSolution Analyst & ArchitectCommented:
Can you please post the link to the video? In the mean time, I'll try looking into your code once again.
AidenAAuthor Commented:
thanks moghazali,

the video is http://www.asp.net/learn/ajax-videos/video-278.aspx

(it is called 'Use ASP.NET AJAX Cascading Drop Down Control to Access a Database')

Muhammad Ousama GhazaliSolution Analyst & ArchitectCommented:
As I mentioned and pointed earlier it is due to the reason of missing CCD controls. The video you pointed were of the days of ATLAS version when ASP.NET AJAX was in Beta. After it matured the case was changed and hence I pointed you to the official sample file which uses same number of CCDs as of DDLs..
For more confirmation to the problem, please see this link and I am hopeful that you would be able to solve the problem: http://forums.asp.net/p/1051586/1486888.aspx#1486888
Hope this helps.
AidenAAuthor Commented:
ok i will look again at this. maybe i don't understand what you mean exactly. I mean, i understand that you need the same number of cascading ddls as dropdownboxes... and they also do in the AJAX video... but, he doesn't need to implement all of them for it to work until the end. i.e. he can implement the first.. test it, then add the second, test it then add the third... etc

And anyway, lets say i had 10 ddls on my page, but only 3 of them were to be used as a cascading dropdownlist, then i would still only need 3 cascading dropdown controls... so just because i have many ddls on my page does not mean i need many cascading dropdown controls also... it is only if i wish to use them as a cascading dropdown list. Otherwise they will just sit there and do nothing until i implement them.

Anyway, let me look at the link and see if i can figure out what you mean... maybe you can see where i'm getting confused also then
AidenAAuthor Commented:

i figured it out...

that was so much more complicated then i thought it would be. Ok, so, I was looking at another post under (http://forums.asp.net/p/1029309/1409070.aspx) and it seems that all sorts of things can cause this error... or, it seems maybe an error in the asmx page causes this. But... VS for some reason doesn't debug this asmx page (or at least whatever settings I had on it doesn't).

So, at the end of that post someone mentions to download something called fiddler which is a web debugging tool. Usually these things require some kind of degree in brain surgery and rocket science combined, but actually this was pretty easy to follow.

I turned on fiddler, ran my application and you can see some requests coming though. One of them was in Red, so this seemed to be the problem. I clicked on that and the following error appeared:

{"Message":"Column \u0027Company Name\u0027 does not belong to table CSAT Data.","StackTrace":"   at System.Data.DataRow.GetDataColumn(String columnName)\r\n   at System.Data.DataRow.get_Item(String columnName)\r\n   at CSATSearchService.GetCSATData(String knownCategoryValues, String category) in E:\\My Documents\\Visual Studio 2005\\WebSites\\CSAT Database\\App_Code\\CSATSearchService.vb:line 22","ExceptionType":"System.ArgumentException"}

So, the reason was to do with my sql query for the ddl. In fact, the column customer name was not in my dataset returned by the sql query, i'd made a mistake there. it works fine now

so actually it had nothing to do with there not be 3 cascading ddl controls as i thought in fact. but thanks for your help anyway... i'll give some marks for the effort!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now