Click here to Skip to main content
15,851,514 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
* Please note UPDATE at the bottom *

I'm just starting to learn C#.NET 4.0 and am doing alright so far. However, I've run into a problem getting Cascading DropDownLists to work correctly in my UpdatePanel. A little overview-- The site uses a master page. On the master page, I have 3 content areas - a header, sidebar, and main content area. The sidebar and main content area are in an updatepanel. This is working very well with part of the site where I have an accordion menu in the sidebar and user controls loading into the main content area depending on what is clicked in the menu. However, I want to add cascading dropdownlists and it doesn't seem to want to work correctly. I've looked over many examples and tried a variety of things I've seen, but they all provide one error or another.

Master page (part of it):
<asp:UpdatePanel runat="server" id="SidebarUpdatePanel" updatemode="Always">
        <div id="sidebar" class="menubar">
            <asp:ContentPlaceHolder ID="SidebarContent" runat="server"/>
        <div class="main">
            <asp:Label ID="lbMasterError" runat="server" CssClass="failureNotification"></asp:Label>
            <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
        <div class="clear">

ASPX (part of it):
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div id="divDetails">
            <table cellspacing="0">
	        <td class="labelfield"><asp:Label ID="lbDevice" runat="server" Text="Device"></asp:Label></td>
	        <td align="left" class="datafield"><asp:DropDownList ID="ddDevice" runat="server" Width="155" AutoPostBack="true" OnSelectedIndexChanged="ddDevice_SelectedIndexChanged"></asp:DropDownList></td>	        </tr>
	        <td class="labelfield"><asp:Label ID="lbManufacturer" runat="server" Text="Manufacturer"></asp:Label></td>
            <td align="left" class="datafield"><asp:DropDownList ID="ddManufacturer" runat="server" Width="155"></asp:DropDownList></td>

Codebehind (part of it):
protected void ddDevice_SelectedIndexChanged(object sender, EventArgs e)
    if (ddDevice.SelectedValue != "")
        int DeviceID = Convert.ToInt32(ddDevice.SelectedValue);
        DataTable dtma = core.Data.ManufacturerDDL(DeviceID);
        dtma.Columns["MA_ID"].ReadOnly = false;
        DataRow drma = dtma.NewRow();
        drma["MA_Name"] = "";
        drma["MA_ID"] = 0;
        dtma.Rows.InsertAt(drma, 0);
        ddManufacturer.DataSource = dtma;
        ddManufacturer.DataTextField = "MA_Name";
        ddManufacturer.DataValueField = "MA_ID";

The goal here is to update the Manufacturer dropdownlist based on what is selected in the device dropdownlist without reloading the entire page. If anyone can offer some suggestions, I'd really appreciate it. Remember that I'm just learning here, so if you don't mind explaining instead of only showing the code, that would be great.

NOTE: The data source is provided from a SQL database in the form of:
MA_ID (int, identity), MA_Name (varchar)

I'm using the selected DeviceID to generate the list of Manufacturers and that's all handled in the stored procedure. That part works. The problem is that when testing this out from the page, it never reaches that part. I'm apparently missing something here.

Thanks! If you need more information, let me know.


Ok, after more testing, it appears that the cascading dropdownlists work as long as I ignore the error message. That's good, but I still don't want to get an error. Here is the error message:

Object doesn't support this property or method

And I'm receiving that from this line that is automatically generated in VS2010:
Sys. WebForms. PageRequestManager. getInstance (). _destroyTree (_3b);

*I added spaces in that line because it was causing problems with the preview on this site.

The error occurs after everything is completed, so it looks like it's trying to update the updatepanel or else reload the page (which it shouldn't be doing) and that's where it has the error message. Considering the dropdownlists are populated, it doesn't appear to be related to that part.

Any help would be greatly appreciated.


I finally narrowed this down to some problem with a Telerik control on the page that is unrelated to the cascading dropdownlists. I still don't know why it doesn't work, but if I remove the radcombobox from further down the page, it works fine. I guess I'll have to post this on their forum even though the cascading dropdownlists aren't using their controls.
Updated 28-Mar-12 7:15am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900