Cascading drop down issue

Posted by Anish_kck under ASP.NET AJAX on 11/3/2010 | Points: 10 | Views : 2028 | Status : [Member] | Replies : 1
I wrote a webservice for cascading dropdownlist as given below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Text;
using System.Data;
using System.Web.Script.Services;
using AjaxControlToolkit;
using System.Collections.Specialized;

/// <summary>
/// Summary description for WebService2
/// </summary>
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
public class WebService2 : System.Web.Services.WebService {

public WebService2()

//Uncomment the following line if using designed components

public string HelloWorld() {
return "Hello World";

public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContentsfrom(string knownCategoryValues, string category)

StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

string[] str = knownCategoryValues.Split(':', ';');

if (str.Length < 1)
return null;

string _ProjectIDs = str[1].ToString();

DataSet _Ds = new DataSet();
DBTask objDBTask = new DBTask();

StringBuilder objBuilder = new StringBuilder();

objBuilder.Append(" SELECT dbo.RntProjectLocationSettings.LocationID, ");
objBuilder.Append(" dbo.RntLocation.Location ");
objBuilder.Append(" FROM dbo.RntProjectLocationSettings INNER JOIN ");
objBuilder.Append(" dbo.RntLocation ON ");
objBuilder.Append(" dbo.RntProjectLocationSettings.LocationID = dbo.RntLocation.LocationID ");
objBuilder.Append(" WHERE dbo.RntProjectLocationSettings.ProjectID= " + _ProjectIDs.ToString()); //NOT WORKING

//objBuilder.Append(" WHERE dbo.RntProjectLocationSettings.ProjectID= 2 " ); ITS WORKING FINE

_Ds = objDBTask.ExecuteDataset(objBuilder.ToString());

List<AjaxControlToolkit.CascadingDropDownNameValue> cascadingValues = new List<AjaxControlToolkit.CascadingDropDownNameValue>();

foreach (DataRow dRow in _Ds.Tables[0].Rows)
string _LocationID = Convert.ToString(dRow["LocationID"].ToString());
string _Location = Convert.ToString(dRow["Location"].ToString());
cascadingValues.Add(new AjaxControlToolkit.CascadingDropDownNameValue(_Location, _LocationID));

return cascadingValues.ToArray();


The line
objBuilder.Append(" WHERE dbo.RntProjectLocationSettings.ProjectID= 2 " ); is working but the line
objBuilder.Append(" WHERE dbo.RntProjectLocationSettings.ProjectID= " + _ProjectIDs.ToString()); is not loading the dropdown list.
Can any one point out the error .

The source code in designer is

<cc1:CascadingDropDown ID="CascadingDropDown4" runat="server" Category="_ProjectIDs"
ParentControlID="ddlProject" ServiceMethod="GetDropDownContentsfrom"
TargetControlID="ddlLocation" ServicePath="WebService2.asmx">

Thanks in advance to all..


Posted by: Vuyiswamb on: 11/3/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

test this first with a normal dropdown. and make sure that all your dropdown have autocomplete set true.

Thank you for posting at Dotnetfunda

Anish_kck, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response