By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,969 Members | 1,536 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,969 IT Pros & Developers. It's quick & easy.

Method error 500

P: n/a

I am trying cascadingdropdown with ajax control. On my form i add 1
combobox and the cascadingdropdown control. When I run the page the
combobox displays the Select... and no options except for

[Method Error 500]

Please help me.

Here is my web service code.

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

/// <summary>
/// Summary description for FoodService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class FoodService : System.Web.Services.WebService
{

public FoodService()
{

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
// public CascadingDropDownNameValue[] GetItemsByCategoryID(string
KnownCategoryValues, string category)
// {
// string[] _categoryValues = KnownCategoryValues.Split(':',
';');
// int _foodID = Convert.ToInt32(_categoryValues[1]);
// List<CascadingDropDownNameValue_foodItems = new
List<CascadingDropDownNameValue>();
// dsFoodTableAdapters.tbparentTableAdapter _foodAdapter =
//new dsFoodTableAdapters.tbparentTableAdapter();
// foreach (DataRow _row in _foodAdapter.GetFoodData())
// {
// _foodItems.Add(new
CascadingDropDownNameValue(_row["category"].ToString(),
_row["categoryID"].ToString()));

// }

// // convert to array and return the vlaues
// return _foodItems.ToArray();
// }
public CascadingDropDownNameValue[] GetItemsByCategoryID(string
KnownCategoryValues)
{
string[] _categoryValues = KnownCategoryValues.Split(':',
';');
int _foodID = Convert.ToInt32(_categoryValues[1]);
List<CascadingDropDownNameValue_foodItems = new
List<CascadingDropDownNameValue>();
// dsFoodTableAdapters.tbparentTableAdapter _foodAdapter =
//new dsFoodTableAdapters.tbparentTableAdapter();
dsFoodItemsTableAdapters.tbChildTableAdapter _foodAdapter =
new dsFoodItemsTableAdapters.tbChildTableAdapter();
foreach (DataRow _row in _foodAdapter.GetData(_foodID))
{
_foodItems.Add(new
CascadingDropDownNameValue(_row["subcategory"].ToString(),
_row["subcategoryID"].ToString()));

}

// convert to array and return the vlaues
return _foodItems.ToArray();
}

}
#######################################

Below is the code for aspx page

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="ObjectDataSource1"
DataTextField="category" DataValueField="categoryID">
</asp:DropDownList><asp:ObjectDataSource
ID="ObjectDataSource1" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetFoodData"
TypeName="dsFoodTableAdapters.tbparentTableAdapter "></
asp:ObjectDataSource>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList><br />
<cc1:CascadingDropDown ID="CascadingDropDown1" runat="server"
Category="tbChild" LoadingText="please wait"
ParentControlID="DropDownList1" PromptText="please subcategory"
ServiceMethod="GetItemsByCategoryID" TargetControlID="DropDownList2">
</cc1:CascadingDropDown>
</form>
</body>
</html>
################################################## ######

Below is the code for aspx.cs page

May 29 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.