Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

Ajax Problem


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_a_CascadingDropDown_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>
            <asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="ObjectDataSource1"
                DataTextField="category" DataValueField="categoryID"
Width="220px">
            </asp:DropDownList><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 />
            <asp:DropDownList ID="DropDownList2" runat="server"
Width="221px">
            </asp:DropDownList><br />
            <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>

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc