J
john_mcmahon
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
ropDownList ID="ddlPlantTypeID" runat="server" Width="326"></
asp
ropDownList><p />
<asp
ropDownList ID="ddlVarietyID" runat="server" Width="326"></
asp
ropDownList>
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
}
}
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
asp
<asp
asp
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
}
}