Array
(
)

Problemas com Cascading DropDown

Lucas Tavares
   - 28 jun 2010

Pessoal ,,,estou tendo problema com a criação de um cascadding dropdown com ajax...ele nao carrega os dropdown´s ..e da uma msg de erro "method error 500"..segue abaixo o codigo...se alguem poder me ajudar eu agradeço...abçs.
defaulf.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="Aluno_Insc.aspx.cs" Inherits="Aluno_Insc" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<%@ Register assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">    <fieldset>    <legend>Formulário de Inscrição</legend>        <table border="0" cellpadding="2" cellspacing="0" width="500">    <tr>        <td width="100">            <b> Selecione a Categoria: </b> </td>        <td>            <asp:DropDownList ID="drdCategory" runat="server">            </asp:DropDownList>                       <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="curso"            TargetControlID="drdCategory" PromptText = "Categoria Selecione" LoadingText="Carregando categorias ..."            ServicePath="processos2.asmx" ServiceMethod="GetDropDownCategories">            </cc1:CascadingDropDown>        </td>    </tr>    <tr>        <td>            <b> Selecionar Produto: </b> </td>        <td>            <asp:DropDownList ID="drdProduct" runat="server" AutoPostBack="True">            </asp:DropDownList>            <cc1:CascadingDropDown ID="CascadingDropDown2" runat="server"                 Category="curso" TargetControlID="drdProduct"            ParentControlID="drdCategory" PromptText="Produto Select"                 LoadingText="Carregando produtos..." ServicePath="processos.asmx"            ServiceMethod="GetDropDownProducts">            </cc1:CascadingDropDown>        </td>    </tr>        </table>        <p></p>        <p><asp:Button ID="btnCadastrar" runat="server" Text="Finalizar Inscrição" />                      </p>                       </fieldset></asp:Content>

codigo asmx (webservice)
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;using System.Data.SqlClient;using AjaxControlToolkit;using System.Data;using System.Collections.Specialized;
/// <summary>/// Summary description for processos2/// </summary>[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService]public class processos2 : System.Web.Services.WebService {
    public processos2 () {
        //Uncomment the following line if using designed components         //InitializeComponent();     }
    [WebMethod]    public string HelloWorld() {        return "Hello World";    }    [WebMethod]    public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownCategories(string knownCategoryValues, string category)    {        SqlConnection sqlConn = new SqlConnection("conexaoBD");        sqlConn.Open();        SqlCommand sqlSelect = new SqlCommand("SELECT [Cod_Curso], [Nome_Curso] FROM [TB_Curso] ORDER BY [Cod_Curso] DESC, [Nome_Curso]", sqlConn);        sqlSelect.CommandType = System.Data.CommandType.Text;        SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlSelect);        DataSet myDataset = new DataSet();        sqlAdapter.Fill(myDataset);        sqlConn.Close();
        List<AjaxControlToolkit.CascadingDropDownNameValue> cascadingValues = new List<AjaxControlToolkit.CascadingDropDownNameValue>();
        foreach (DataRow dRow in myDataset.Tables[0].Rows)        {            string categoryID = dRow["Cod_Curso"].ToString();            string categoryName = dRow["Nome_Curso"].ToString();            cascadingValues.Add(new AjaxControlToolkit.CascadingDropDownNameValue(categoryName, categoryID));        }
        return cascadingValues.ToArray();    }
    [WebMethod]    public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownProducts(string knownCategoryValues, string category)    {        int categoryID;
        StringDictionary categoryValues = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        categoryID = Convert.ToInt32(categoryValues["curso"]);
        SqlConnection sqlConn = new SqlConnection("conexaoBD");        sqlConn.Open();        SqlCommand sqlSelect = new SqlCommand("SELECT TB_Curso.Cod_Curso, TB_Curso_Pagto.Cod_Pagto, TB_Curso_Pagto.Forma_Pagto FROM TB_Curso INNER JOIN TB_Curso_Pagto ON TB_Curso.Cod_Curso = TB_Curso_Pagto.Cod_Curso WHERE TB_Curso_Pagto.Cod_Curso = @Cod_Curso", sqlConn);        sqlSelect.CommandType = System.Data.CommandType.Text;        sqlSelect.Parameters.Add("@Cod_Curso", SqlDbType.Int).Value = categoryID;        SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlSelect);        DataSet myDataset = new DataSet();        sqlAdapter.Fill(myDataset);        sqlConn.Close();
        List<AjaxControlToolkit.CascadingDropDownNameValue> cascadingValues = new List<AjaxControlToolkit.CascadingDropDownNameValue>();
        foreach (DataRow dRow in myDataset.Tables[0].Rows)        {            string productID = dRow["Cod_Pagto"].ToString();            string productName = dRow["Forma_Pagto"].ToString();            cascadingValues.Add(new AjaxControlToolkit.CascadingDropDownNameValue(productName, productID));        }
        return cascadingValues.ToArray();    }    }