Cannot get 'result' for AjaxData:Gridview

Last post 06-02-2009 9:10 AM by Sonu. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 05-27-2009 7:13 AM

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Cannot get 'result' for AjaxData:Gridview

    Hello all,

     I am using the AjaxData:Gridview. I am calling a web service to retrieve a datatable. The data is received because thru Firebug I can see the JSON output in the Web service Response. However, it does not load the 'result' into the ajaxdata:gridview on the page. I have looked thru the examples and cannot find a solution.

    In debugging the javascript in VS, it states that 'result' is undefined ??

    Here is the code:

    function pageLoad(sender, e){
    	var zCode = "22153"
    	var radius = 20;
    	DataService.ByZipCodeOrCity(zCode, radius, onLoadSuccess);
    }
    
    function onLoadSuccess(result){
    	var gridView = $find('_ctl0_cphContent_ajaxGVResults');
    
    	gridView.set_dataSource(result.Rows);
    	gridView.dataBind();
    }

    I have a breakpoint at gridView.set_dataSource, that is where VS says 'result'= undefined, after the break it just displays the the no data text in ajaxdata:gridview.

    I have the ajaxdatacontrols.dll and microsoft.web.preview.dll in the bin folder and the following in my web.config.

     

  •  Advertisement

    Featured Advertisement

     
  • 05-27-2009 7:34 AM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Cannot get 'result' for AjaxData:Gridview

    I am not sure if the second parameter is required in the callback function, but try to change the function to:

    function onLoadSuccess(result, eventArgs)
    {
    ....
    }

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-27-2009 9:27 AM In reply to

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Re: Cannot get 'result' for AjaxData:Gridview

     Thanks for the quick response Sonu.

    I'm looking forward to getting this working. However, your suggestion yielded the same result.

    In debug- result = undefined

    gridview - no data

  • 05-27-2009 9:34 AM In reply to

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Re: Cannot get 'result' for AjaxData:Gridview

     I tried returning a table without sending variables and get the same result.

  • 05-27-2009 10:05 AM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Cannot get 'result' for AjaxData:Gridview

    Can you try that with a new asp.net ajax project without using the AjaxDataControls? Its clearly that this has nothing to do with the controls.

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-27-2009 4:59 PM In reply to

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Re: Cannot get 'result' for AjaxData:Gridview

     Sonu,

    I found that I had an old Futures release. July instead of January.

    Now I am getting the error: Type: 'DataSetConverter' does not inherits from JavaScriptConverter.

  • 05-27-2009 8:44 PM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Cannot get 'result' for AjaxData:Gridview

    Take a look at this post:

    http://dotnetslackers.com/Community/blogs/sonukapoor/archive/2008/06/13/ajaxdatacontrols-adc-faq-how-to-get-started-with-the-ajaxdatacontrols-with-visual-studio-2005.aspx

    You need to add the converter to the web.config. The above post will show you how.

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-28-2009 7:27 AM In reply to

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Re: Cannot get 'result' for AjaxData:Gridview

     Been down that path. The converter is in the web.config. I went through your tutorial first.

    I'm wondering if I have all the DLLs referenced properly.

    Brian

  • 05-28-2009 11:03 AM In reply to

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Re: Cannot get 'result' for AjaxData:Gridview

     Ok, I had to replace the DLL in my BIN. I did not have an updated DLL for Preview. I have the web.config set up.

    Now I see the datatable in VS Output, but when it goes to this gridview.set_datasource i get the following error

    Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'Object' cannot be converted to type 'Array'.
    Parameter name: value

    Brian

  • 05-28-2009 11:10 AM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Cannot get 'result' for AjaxData:Gridview

    You are still returning a DataTable, right? What version of the ADC controls are you using? Right click on the dll and check the version tab. The latest beta is: 2.0.3322.23006, which you can get from:

    http://dotnetslackers.com/Community/forums/please-try-out-latest-pre-beta-release-of-the-ajaxdatacontrols/t/3084.aspx

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-28-2009 1:07 PM In reply to

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Re: Cannot get 'result' for AjaxData:Gridview

     I have downloaded the latest beta and placed it in the BIN. The error I'm getting is in the ScriptResource - under MicrosoftAjax.js, Is it not referencing the right ajax dll?

    Thanks again for your help, almost there.

  • 05-28-2009 1:17 PM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Cannot get 'result' for AjaxData:Gridview

    What is the exact error message? Can you download the demo from the same thread and compare the versions of the dll with yours?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-28-2009 2:40 PM In reply to

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Re: Cannot get 'result' for AjaxData:Gridview

    Yes, I am returning a Datatable.  I am in C# not VB.

     

     

    [

    WebMethod]

     

     

    public DataTable ByZipCodeOrCity(string zCode, float zRadius)

    DataTable dtResults = new DataTable();

    ... call db and get result through tableadapter call to storedprocedure ....

    return dtResults;

     



    In the 'Locals' in VS, I noticed your 'result' contains __type as system.data.datatable with your columns and rows. Mine does not have the _type, it is an Object while your's is a string. It must not be converting.

    Here is the error:

    Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'Object' cannot be converted to type 'Array'.
    Parameter name: value

    Brian

  • 05-28-2009 2:46 PM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Cannot get 'result' for AjaxData:Gridview

    Make sure that you have this in your web.config:

    <jsonSerialization maxJsonLength="4194304">
      <converters>
        <add name="DataSetConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview"/>
        <add name="DataRowConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview"/>
        <add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter, Microsoft.Web.Preview"/>
      </converters>
    </jsonSerialization>

    Besides that you will need to download the ASP.NET Futures and add the binaries Microsoft.Web.Preview.dll to your website project.

    This should go in between the <scripting>/<webServices> section.

    See if you can get this solution working: http://dotnetslackers.com/Community/blogs/sonukapoor/ADCSampleWebsite.zip

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 06-01-2009 6:39 AM In reply to

    • balmeter
    • Top 150 Contributor
    • Joined on 05-27-2009
    • Wannabe Slacker
    • Points 66

    Re: Cannot get 'result' for AjaxData:Gridview

     Sonu,

    I've got it working. A few days rest and actually shutting down Windows (instead of Hibernating) fixed it. I think I had clear my machine to reference the right DLLs.  I also set it to result.rows.

    Thanks for all your help. I may be back to ask more. In the meantime, check out my friend in Montreal, www.timrideout.com.

    Brian Almeter

Page 1 of 2 (16 items) 1 2 Next >