470,631 Members | 1,621 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

ISSUE WITH AJAX CASCADING DROP DOWN CONTROL

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" %>
<cc1:CascadingDropDown ID="cddPlantType" runat="server"
TargetControlID="ddlPlantTypeID" Category="Plant Types"
LoadingText="Loading Plant Types..." PromptText="Select a Plant Type"
ServicePath="~/customcontrols/plantdetail.asmx"
ServiceMethod="GetPlantTypes" />
<cc1:CascadingDropDown ID="cddVarietyType" runat="server"
TargetControlID="ddlVarietyID" Category="Variety Types"
LoadingText="Loading Plant Varieties..." PromptText="Select a Plant
Variety" ServicePath="~/customcontrols/plantdetail.asmx"
ServiceMethod="GetPlantVarieties" ParentControlID="ddlPlantTypeID" />
<asp:ScriptManager ID="smCascadingDropDown"
EnablePartialRendering="false" runat="server" />
<asp:DropDownList ID="ddlPlantTypeID" runat="server" Width="326"></
asp:DropDownList><p />
<asp:DropDownList ID="ddlVarietyID" runat="server" Width="326"></
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>
/// Summary description for plantdetail
/// </summary>
[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<CascadingDropDownNameValuevalues = new
List<CascadingDropDownNameValue>();
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(k nownCategoryValues);

// 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<CascadingDropDownNameValuevalues = new
List<CascadingDropDownNameValue>();
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
}
}
Jan 4 '08 #1
0 1372

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Scott McChesney | last post: by
5 posts views Thread by Colin Walls | last post: by
3 posts views Thread by =?Utf-8?B?R2FyeSBM?= | last post: by
1 post views Thread by jrcapp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.