ISSUE WITH AJAX CASCADING DROP DOWN CONTROL

ISSUE WITH AJAX CASCADING DROP DOWN CONTROL

am 04.01.2008 06:46:25 von phreeskier

I'm having issues populating a second drop down menu that's dependent
upon a selection in the first menu. When I select an option from the
first menu, the second menu remains disabled, i.e. unable to select an
option. I'm confident that most of my code is correct because of
testing that I completed with it. For instance, when I remove the
ParentControlID attribute from the second control and un-comment out:
// string sPlantTypeID = "2";
// int iPlantTypeID = LT.Utils.CInt(sPlantTypeID);

and comment out:
int iPlantTypeID;
if (!kv.ContainsKey("PlantTypeDescription") || !
Int32.TryParse(kv["PlantTypeDescription"], out iPlantTypeID))
{
return null;
}

I receive the data that I hope to in the second menu.

The one million dollar question is, what's causing the second menu to
not populate when an option is selected from the first menu?

Thanks for your help.
John

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="plantgrid.ascx.cs"
Inherits="FPSweb.usercontrols.plantgrid" %>
<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
TargetControlID="ddlPlantTypeID" Category="Plant Types"
LoadingText="Loading Plant Types..." PromptText="Select a Plant Type"
ServicePath="~/customcontrols/plantdetail.asmx"
ServiceMethod="GetPlantTypes" />
TargetControlID="ddlVarietyID" Category="Variety Types"
LoadingText="Loading Plant Varieties..." PromptText="Select a Plant
Variety" ServicePath="~/customcontrols/plantdetail.asmx"
ServiceMethod="GetPlantVarieties" ParentControlID="ddlPlantTypeID" />
EnablePartialRendering="false" runat="server" />
asp:DropDownList>


asp:DropDownList>

using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.Script.Services;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using BusinessLayer;
using AjaxControlToolkit;

namespace FPSweb.customcontrols
{
///


/// Summary description for plantdetail
///

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
[ToolboxItem(false)]
public class plantdetail : System.Web.Services.WebService
{
private string err;

#region methods

[WebMethod]
public CascadingDropDownNameValue[] GetPlantTypes(string
knownCategoryValues, string category)
{
DataTable dtPlantTable = Common.GetPlantTypes(0, out err);
List values = new
List();
foreach (DataRow dr in dtPlantTable.Rows)
{
string sPlantTypeDescription =
(string)dr["PlantTypeDescription"];
int iPlantTypeID = (int)dr["PlantTypeID"];
values.Add(new
CascadingDropDownNameValue(sPlantTypeDescription,
iPlantTypeID.ToString()));
}
return values.ToArray();
}

[WebMethod]
public CascadingDropDownNameValue[] GetPlantVarieties(string
knownCategoryValues, string category)
{
StringDictionary kv =
CascadingDropDown.ParseKnownCategoryValuesString(knownCatego ryValues);

// string sPlantTypeID = "2";
// int iPlantTypeID = LT.Utils.CInt(sPlantTypeID);

int iPlantTypeID;
if (!kv.ContainsKey("PlantTypeDescription") || !
Int32.TryParse(kv["PlantTypeDescription"], out iPlantTypeID))
{
return null;
}

DataTable dtVarietyTable = Common.GetVarieties(0,
iPlantTypeID, out err);

List values = new
List();
foreach (DataRow dr in dtVarietyTable.Rows)
{
string sVarietyDescription =
(string)dr["varietyDescription"];
int iVarietyID = (int)dr["varietyID"];
values.Add(new
CascadingDropDownNameValue(sVarietyDescription,
iVarietyID.ToString()));
}

return values.ToArray();
}

#endregion methods
}
}