Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 CascadingDropDown Extender Not Binding with Dropdo

Author  Topic 

User8462
Starting Member

3 Posts

Posted - 2010-06-21 : 18:14:40
I am experiencing an unexpected problem, and I am hoping someone here can help. I am trying to create a cascading dropdown list using two dropdown lists in Visual Studio 2008 Professional connecting to a SQL Server 2008 Standard database on my local machine. I have added the two dropdown lists, as well as a CascadingDropDown extender from the AJAX Control Toolkit that corresponds with the first dropdown list. The problem I am running into is that despite the fact that I have a CascadingDropDown extender for the first dropdown list so far, and the extender is configured properly, the first dropdown list is showing Unbound in Design view. I also don't see a TargetControlID entry in the properties window for the extender. I hard coded the TargetControlID to the extender in the Source view and, although I am not receiving any dynamic errors from the TargetControlID entry (meaning, the TargetControlID is a valid parameter, and the dropdown list I entered for that parameter exists on the same page), the dropdown list doesn't populate properly and when in Design view, not only do I not see an entry for the CascadingDropDown extender, but the target dropdown list shows as being "Unbound."

A couple of things I want to point out first:

1) I am using Master pages on this site for the header, footer and navigation. The opening and closing <form> tags, as well as the <ScriptManager> entry are in the Master page, not the content pages. I did this with the assumption that at runtime, each page would have the proper <form> tags and <ScriptManager> entry to function properly.

2) I have been able to add a CascadingDropDown extender to a page in Design view (and it initially displays properly), but by the time I have added all of the properties settings to apply it to its corresponding dropdown list, the entry appears normal in Source view but no longer appears in Design view.

When I run the page, the dropdown list does not populate. Obviously, I assume that this is related to the dropdown list showing in Design view as being Unbound, but I don't know how to get the dropdown list to recognize that I have a CascadingDropDown extender that is supposed to apply to it.

Here is what the two elements look like in Source view:

<asp:DropDownList ID="ddlCompany" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="cddCompanies" runat="server" TargetControlID="ddlCompany" Category="Company" PromptText="Select a Company" LoadingText="Please Wait..." ServicePath="~/CompaniesService.asmx" ServiceMethod="GetCompanies">
</ajaxToolkit:CascadingDropDown>

To create these, I have been following Joe Stagner's example in his video on the topic (http://www.asp.net/ajax/videos/use-aspnet-ajax-cascading-drop-down-control-to-access-a-database) virtually word for word. I have set up a TableAdapter/DataSet, one for the dropdown list, and the dataset is able to accurately pull the appropriate data from the database, so I know it is working properly. I believe the problem is that the dropdown list isn't binding with the CascadingDropDown extender properly. It wouldn't bother me that I don't see a TargetControlID entry in the properies window for the CascadingDropDown extender, although I have a feeling that the absense of that property is related to the fact that the dropdown list is not binding to the extender.

I don't think the content of the CompaniesService.asmx.cs file dictates whether the dropdown list displays Bound versus Unbound, but here is the CompaniesService.asmx.cs file for reference:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using AjaxControlToolkit;
using System.Data;
using System.Data.SqlClient;

namespace AS_Admin
{
/// <summary>
/// Summary description for CompaniesService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class CompaniesService : System.Web.Services.WebService
{

[WebMethod]
public CascadingDropDownNameValue[] GetCompanies(string knownCategoryValues, string category)
{
dsCompaniesTableAdapters.CompanyTableAdapter companyAdapter = new dsCompaniesTableAdapters.CompanyTableAdapter();
dsCompanies.CompanyDataTable companies = companyAdapter.GetAllCompanies();
List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
foreach (DataRow dr in companies)
{
string comp = (string)dr["CompanyName"];
string compID = (string)dr["CompanyID"];
values.Add(new CascadingDropDownNameValue(comp, compID));
}
return values.ToArray();
}
}
}

I searched online for causes to this problem, but I wasn't able to find any solutions. If anyone can help me, I would greatly appreciate it.

Thanks in advance.

User8462
Starting Member

3 Posts

Posted - 2010-06-25 : 13:05:05
Does anyone have any ideas on this? I've tried making all of the adjustments that may be causing the problem, but none of them worked. This seems like a pretty straight-forward process, but something's definitely preventing the data from being bound to the dropdown list. Any ideas would be greatly appreciated.
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-06-25 : 13:55:17
Check whether you have set all the properties required as mentioned here.

http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Walkthrough/CCDWithDB.aspx


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

User8462
Starting Member

3 Posts

Posted - 2010-06-27 : 15:29:42
I actually used that Walkthrough as a guide when I first built the control. I have gone over all of the code numerous times, and I don't see any problems. In fact, I have since found that by adding the TargetControlID to the extender, that's the step where the extender disappears from the Design view and the status of the dropdown list switches to "Unbound." I'm at the point where I think I'll have to create the functionality without the CascadingDropDown extender control. Do you have any tips on how to handle that efficiently?
Go to Top of Page
   

- Advertisement -