ISSUE WITH AJAX CASCADING DROP DOWN CONTROL

Discussion in 'ASP .Net' started by john_mcmahon@gap.com, Jan 4, 2008.

  1. Guest

    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<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(knownCategoryValues);

    // 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
    }
    }
     
    , Jan 4, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    817
    Ben Strackany
    Jan 7, 2005
  2. Replies:
    0
    Views:
    437
  3. weiwei
    Replies:
    0
    Views:
    1,072
    weiwei
    Jan 5, 2007
  4. Michel Couche

    Cascading radiobutton group/drop down list

    Michel Couche, Apr 28, 2007, in forum: Javascript
    Replies:
    1
    Views:
    185
    shimmyshack
    Apr 29, 2007
  5. OccasionalFlyer

    Cascading drop-down restructuring

    OccasionalFlyer, Feb 7, 2011, in forum: Javascript
    Replies:
    12
    Views:
    191
    Thomas 'PointedEars' Lahn
    Feb 24, 2011
Loading...

Share This Page