Ajax Toolkit: CascadingDropDown - [Method Error 12030]

M

mark4asp

I'm accessing the website locally via IIS. I get an error message
shown in DropDownList2: [Method Error 12030]

I can't see what I'm doing wrong.

I changed CascadingDropDown1.Category from "Continent" to "countrys"
and my error changed to 12031 instead.

What is the purpose of this property anyway?

=======================================================
Code
=======================================================

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<br />
<asp:ObjectDataSource ID="ods_Continents" runat="server"
SelectMethod="GetContinents" TypeName="MandateDAL" />
<div>
Continent:&nbsp;
<asp:DropDownList ID="ddlContinents" runat="server"
DataSourceID="ods_Continents"
DataTextField="ContinentName"
DataValueField="ContinentID" />
<br /><br />
Country:&nbsp;<asp:DropDownList ID="ddlCountries"
runat="server" /><br /><br />
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1"
runat="server" Category="countrys"
LoadingText="Please wait..."
ParentControlID="ddlContinents" PromptText="Select a Country"
TargetControlID="ddlCountries"
ServicePath="CountryService.asmx"
ServiceMethod="GetCountriesByContinentId" />
</div>
</form>
</body>
</html>


=======================================================
CountryService.asmx (code behind)
=======================================================

using System;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.Services;
using System.Web.Services.Protocols;
using AjaxControlToolkit;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for CountryService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class CountryService : System.Web.Services.WebService
{
public CountryService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public CascadingDropDownNameValue[] GetCountriesByContinentId(string
knownCategoryValues, string category)
{
StringDictionary kv =
CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
int continentId;
if (!kv.ContainsKey("ContinentName") || !
Int32.TryParse(kv["ContinentName"], out continentId))
{
return null;
}
DataTable countrys = MandateDAL.GetCountries(continentId);
List<CascadingDropDownNameValue> values = new
List<CascadingDropDownNameValue>();
foreach (DataRow dr in countrys.Rows)
{
values.Add(new
CascadingDropDownNameValue((string)dr["CountryName"],
dr["CountryId"].ToString()));
}
return values.ToArray();
}
}


=======================================================
MandateDAL.GetCountries() - This works (and has been independently
tested)
=======================================================

public static DataTable GetCountries(int ContinentID)
{
data_connection dConn = new data_connection(true);
_connection = dConn;
if (_connection.Connect())
{
SqlCommand cmd = new SqlCommand("Watch_GetCountries",
_connection.Connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@ContinentID", System.Data.SqlDbType.Int, 4,
"").Value = ContinentID;

DataTable countries = new DataTable();
countries.Columns.Add("CountryId", typeof(int));
countries.Columns.Add("CountryName", typeof(string));

SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
DataRow dr = countries.NewRow();
dr[0] = (int)reader["CountryId"];
dr[1] = reader["CountryName"].ToString();

countries.Rows.Add(dr);
}
reader.Close();
return countries;
}
else
return null;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top