PC Review


Reply
Thread Tools Rate Thread

Ajax Problem

 
 
bbawa1@yahoo.com
Guest
Posts: n/a
 
      30th May 2007
Hi Phani,

I have two tables. I created datasets dsPrimary and dsChild. For
dsPrimary.xsd my query is For first dropdown list my query is select
* from tbparent

For second dataset dsChild.xsd my query is
select categoryid, subcategoryid, subcategory
from tbchild where categoryid = @categoryid.

I Created an ObjectDataSource to display all the Items from tbparent
table available in the first dropdownlist . By default all the
parentitems available in tbparent table will be shown when the page
loads.

My problem is when I call a web method from my web service to populate
the second dropdown list based on the item choosen from first dropdown
list. It shows Method Error 505 instead of showing the items from the
tbChild table.

I am sending you all my cs and asmx files so, that you can have a look
on that.

I am following this link for tutorial
http://aspalliance.com/1183_Creating...own_Using_AJAX.

I appreciate your help

tbparent
categoryID category
----------- -------------
1 fruits
2 vegetables
3 meats

tbChild
categoryID subcategoryID subcategory
----------- ------------- -------------
1 1 apple
1 2 orange
1 3 banana
2 4 brocoli
2 5 celery
2 6 squash
3 7 ham
3 8 turkey
3 9 chicken

################################################################
Here is my web service

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[] GetChildData(string
KnownCategoryValues, string category)
{
string[] _categoryValues = KnownCategoryValues.Split(':',
';');
int _foodID = Convert.ToInt32(_categoryValues[1]);
List<CascadingDropDownNameValue> _foodItems = new
List<CascadingDropDownNameValue>();

dsChildTableAdapters.tbChildTableAdapter _foodAdapter = new
dsChildTableAdapters.tbChildTableAdapter();

foreach (DataRow _row in _foodAdapter.GetChildData(_foodID))
{
_foodItems.Add(new
CascadingDropDownNameValue(_row["subcategory"].ToString(),
_row["subcategoryID"].ToString()));

}

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


}

####################################################################
Here is my Default.aspx page

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

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

<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<aspropDownList ID="DropDownList1" runat="server"
DataSourceID="ObjectDataSource1"
DataTextField="category" DataValueField="categoryID"
Width="220px">
</aspropDownList><asp:ObjectDataSource
ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"
InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetParentData"
TypeName="dsPrimaryTableAdapters.tbparentTableAdapter"
UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_categoryID"
Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="category" Type="String" />
<asp:Parameter Name="Original_categoryID"
Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="category" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
<br />
<aspropDownList ID="DropDownList2" runat="server"
Width="221px">
</aspropDownList><br />
&nbsp;<cc1:CascadingDropDown ID="CascadingDropDown1"
runat="server" Category="category"
LoadingText="please select"
ParentControlID="DropDownList1" PromptText="please select"
ServiceMethod="GetItemsByCategoryID"
TargetControlID="DropDownList2">
</cc1:CascadingDropDown>
</div>
</form>
</body>
</html>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET AJAX samples... I am looking for help with HoverMenu AJAX Toolbox control. JDeats Microsoft ASP .NET 1 5th Oct 2007 08:50 PM
Ajax en the Form_load event and Ajax in serveruser controls =?Utf-8?B?VG9u?= Microsoft ASP .NET 2 22nd Jun 2007 10:16 AM
ASP.NET and AJAX: JavaScript files from the Microsoft AJAX Library Nathan Sokalski Microsoft ASP .NET 2 2nd Jun 2007 01:07 AM
ASP.NET AJAX Enabled Website Web.config error (newbie to AJAX) Tony K Microsoft ASP .NET 2 4th May 2007 05:23 AM
Deploying ASP.NET AJAX-Enabled Web site to host without AJAX insta =?Utf-8?B?QnJpYW4gRWR3YXJkcw==?= Microsoft ASP .NET 2 21st Feb 2007 10:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:01 AM.