Method error 500

B

bbawa1

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
 

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,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top