Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ISSUE WITH AJAX CASCADING DROP DOWN CONTROL

Reply
Thread Tools

ISSUE WITH AJAX CASCADING DROP DOWN CONTROL

 
 
john_mcmahon@gap.com
Guest
Posts: n/a
 
      01-04-2008
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" />
<aspropDownList ID="ddlPlantTypeID" runat="server" Width="326"></
aspropDownList><p />
<aspropDownList ID="ddlVarietyID" runat="server" Width="326"></
aspropDownList>

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<CascadingDropDownNameValue> values = 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<CascadingDropDownNameValue> values = 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
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Cascading drop-down restructuring OccasionalFlyer Javascript 12 02-24-2011 08:52 PM
Cascading radiobutton group/drop down list Michel Couche Javascript 1 04-29-2007 01:56 AM
ASP.NET AJAX Control Tookit - cascading drop down robert@orisoft.co.uk ASP .Net 0 11-15-2006 11:50 PM
Ajax and cascading drop downs Colin Walls Javascript 5 07-07-2005 04:51 PM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM



Advertisments