Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

DynamicPopulateExtender & Drop Down Lists

Last post 12-13-2007, 1:46 PM by jfbchill. 2 replies.
Sort Posts: Previous Next
  •  11-20-2007, 7:02 PM 36741

    DynamicPopulateExtender & Drop Down Lists

    I really need some help. I've spent the past two hours trying to figure this out... and I can't. I don't know what I'm doing wrong.

    This is on my Default.aspx page:

    <asp:DropDownList ID="ddlMagazineList" runat="server" DataSourceID="MagazinesDataSource" OnSelectedIndexChanged="updateKey(this.value);"
        DataTextField="Name" DataValueField="Id">
    </asp:DropDownList><asp:SqlDataSource ID="MagazinesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="Get_Magazine_List" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    <asp:Panel ID="panel1" style='width:100px; height:100px' BorderWidth='1' runat='server'>
    <ajaxToolkit:DynamicPopulateExtender ID="dp1" runat="server"
        UpdatingCssClass="dynamicPopulate_Updating" />

    On the code behind, I have the following:

    using System.Web.Services;
    using System.Web.Script.Services;
    using System.IO;
    using AjaxControlToolkit;

    public partial class _Default : System.Web.UI.Page
        public string GetHtml(string contextKey)
            string html = GetProducts(Convert.ToInt32(contextKey));
            return html;
        private string GetProducts(int categoryID)
            string connectionString = "Server=localhost;Database=Northwind;Trusted_Connection=true";
            SqlConnection myConnection = new SqlConnection(connectionString);
            SqlCommand myCommand = new SqlCommand("SELECT ProductID, ProductName FROM Products WHERE CategoryID = @CategoryID", myConnection);
            myCommand.Parameters.AddWithValue("@CategoryID", categoryID);
            SqlDataAdapter ad = new SqlDataAdapter(myCommand);
            DataSet ds = new DataSet();
            GridView gv = new GridView();
            gv.ID = "GridView1";
            gv.DataSource = ds;
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            return sw.ToString();

    Running that, I get the error CS1026: ) expected in regards to the OnSelectedIndexChanged="updateKey(this.value);"

    I've also tried removing that from the DropDownList and changing the DynamicPopulateExtender to:

    <ajaxToolkit:DynamicPopulateExtender ID="dp1" runat="server"
        UpdatingCssClass="dynamicPopulate_Updating" />

    This doesn't give a .NET error, but when you select something it returns "Web Service call failed: 500."

    In my opinion, that is a horrible error for me... as I have no idea WHY it failed.  

    I really don't know... if someone could point me in the right direction I would really, truly appreciate it! Thank you!

    Andrew Tatum

  •  12-07-2007, 2:41 AM 37349 in reply to 36741

    Re: DynamicPopulateExtender & Drop Down Lists

    What is the web server you are using?
  •  12-13-2007, 1:46 PM 37649 in reply to 36741

    Re: DynamicPopulateExtender & Drop Down Lists

    Hi Drew -

    The one thing I've teased out is that it's a data length problem - you might try trimming the length of the string you return from the web service invocation  just as an experiment (see below).

    I'm running into a similar issue - though I'm combining DynamicPopulate with the Accordion control.  Error 500's everywhere, so I've single stepped the web method and some of the client javascript (with FireBug) and I'm flummoxed as to the root cause from a javascript perspective so don't have a fix.

     I am using the web service call to specifically avoid getting gobs of data from my data source when the page is first rendered.  Hence, I get a good scoop of data with each ajax web service based call.  I had to trim down the length of the results string to get the error 500's to go away.  It doens't seem to me that any embedded html markup in the return string was the culprit, as stripping all html markup from the return string didn't help.

     102,348 seems the max string I can return before I get the error 500 at the client.





View as RSS news feed in XML