CodeSmith Community
Your Code. Your Way. Faster!

Paging DataSets on a webpage using custom stored procedures

Latest post 09-26-2008 6:57 PM by mark.zigman. 4 replies.
  • 10-10-2006 5:21 AM

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 924
    • Points 34,750

    Paging DataSets on a webpage using custom stored procedures

    OK, so you want to use a dataset returned from a custom stored proc (csp) in web page, but don't want to do any of the paging plumbing yourself.

    Specify your csp such that it will be picked up by NT and returns a dataset i.e. make sure the columns don't match the parent entity. NT will automatically generate the code to handle the paging for you in the data layer.  If you generate the service layer they will also be picked up there to.

    Ok so how do we get it on our web page.  Create an ObjectDataSource in the following manner: 

    <asp:ObjectDataSource runat="server" ID="ods" TypeName="MySystem.Services.ProductService" SelectMethod="GetNoProductSite"  />

    Note the TypeName and SelectMethod point to the service and method you want to execute.

    You can then create an EntityGridView and link to the data source using the datasourceid. Enable paging and away you go! 

    swin

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 105
  • 10-19-2006 12:10 PM In reply to

    Re: Paging DataSets on a webpage using custom stored procedures

    Great tip Swin!!

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 01-30-2007 2:37 AM In reply to

    • skbach
    • Top 75 Contributor
    • Joined on 01-18-2007
    • Vancouver, British Columbia
    • Posts 58
    • Points 1,470

    Re: Paging DataSets on a webpage using custom stored procedures

    Swin/Robert,

    What is meant by "NT will automatically generate the code to handle the paging for you in the data layer."?

    I expected this solution returns ALL results and then pages through them, similarly to the way .NET works without .NETTiers. (using Gridview and Objectdatasource).

    Or does the statement mean that .NETTiers is somehow customizing the paging to avoid this inefficiency?

    Thanks.
     

    Scott Klarenbach PointyHat Software www.pointyhat.ca _______________________________________ To iterate is human; to recurse, divine
    • Post Points: 5
  • 01-27-2008 9:02 AM In reply to

    • mr.msobhy
    • Not Ranked
    • Joined on 03-31-2007
    • Posts 4
    • Points 110

    Re: Paging DataSets on a webpage using custom stored procedures

    swin:

    OK, so you want to use a dataset returned from a custom stored proc (csp) in web page, but don't want to do any of the paging plumbing yourself.

    Specify your csp such that it will be picked up by NT and returns a dataset i.e. make sure the columns don't match the parent entity. NT will automatically generate the code to handle the paging for you in the data layer.  If you generate the service layer they will also be picked up there to.

    Ok so how do we get it on our web page.  Create an ObjectDataSource in the following manner: 

    <asp:ObjectDataSource runat="server" ID="ods" TypeName="MySystem.Services.ProductService" SelectMethod="GetNoProductSite"  />

    Note the TypeName and SelectMethod point to the service and method you want to execute.

    You can then create an EntityGridView and link to the data source using the datasourceid. Enable paging and away you go! 

    swin

     

     

    mt too want to know the meaning of those words 

    • Post Points: 35
  • 09-26-2008 6:57 PM In reply to

    Re: Paging DataSets on a webpage using custom stored procedures

    You can then create an EntityGridView and link to the data source using the datasourceid. Enable paging and away you go! 

     Paging is working...But I do not have a total record count and when I try to export to excel I get the following error???

     

    Specified argument was out of the range of valid values.
    Parameter name: value

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: value

    Source Error:

    Line 565:
    Line 566:            this.PageIndex = 0;
    Line 567:            this.PageSize = this.RecordsCount;
    Line 568:            this.DataSourceID = this.DataSourceID;
    Line 569:            this.DataBind();

     

    Is it possible to use the excel and total records of the footer when using a custom sproc?

    • Post Points: 5
Page 1 of 1 (5 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems