Paging with GetMultiAsDataTable

Posts   
 
    
Posts: 24
Joined: 24-Jan-2005
# Posted on: 28-Jun-2007 15:07:37   

Hello,

I've been trying to get paging working with a query and the pagesize is working however the page isn't; it's always page one.

I'm using LLBLGen 1.0.2005.1 Final (July 6th 2006)

Any ideas?

Thanks, Mike


TypedListDAO dao = new TypedListDAO();

            int pageSize = int.Parse(ConfigurationSettings.AppSettings["searchListPageSize"]);
            
            if(ViewState["Pages"]==null)
            {
                int totalOrders = dao.GetDbCount(fields, null, where, rels, groupByClause);
                ViewState["TotalOrders"] = totalOrders;
                int pageCount = Convert.ToInt32(Math.Ceiling(((double)totalOrders/(double)pageSize)));
                DataTable pages = new DataTable();
                pages.Columns.Add(new DataColumn("PageNumber", typeof(int)));
                for(int i=1; i<=pageCount; i++)
                {
                    DataRow newRow = pages.NewRow();
                    newRow["PageNumber"] = i;
                    pages.Rows.Add(newRow);
                }
                ViewState["Pages"] = pages;
            }
            rptPages.DataSource = (DataTable)ViewState["Pages"];
            rptPages.DataBind();
            numberOfResults = ((int)ViewState["TotalOrders"]).ToString() + " results found";            

            if(ViewState["CurrentPage"]!=null)
            {
                currentPage = (int)ViewState["CurrentPage"];
            }
            DataTable tl = new DataTable();
            dao.GetMultiAsDataTable(fields, tl, 0, sorter, where, rels, true, groupByClause, null, currentPage, pageSize);

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Jun-2007 15:29:11   

if(ViewState["CurrentPage"]!=null) { currentPage = (int)ViewState["CurrentPage"]; } DataTable tl = new DataTable(); dao.GetMultiAsDataTable(fields, tl, 0, sorter, where, rels, true, groupByClause, null, currentPage, pageSize);

Where do you set the ViewState["CurrentPage"]? it seems to me that you are always passing the current page.

If this is not the case would you please specify the runtime library version you are using?

Posts: 24
Joined: 24-Jan-2005
# Posted on: 28-Jun-2007 18:01:14   

Hi there,

I set the ViewState["CurrentPage"] in the command event of the linkbuttons to select the page. They then run the search again with the correct page set. I've debugged this bit and it definitely changed the page number. The runtime library version are (i think):

SD.LLBLGen.Pro.DQE.SqlServer.NET11.dll 1.0.20051.060516 SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll 1.0.20051.060317

Thanks, hope you can help. Let me know if there's anything else you need.

Mike

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 29-Jun-2007 10:02:24   

SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll 1.0.20051.060317

That's a little bit old, would you please download and try the latest avilable build? And tell me if the problem still exists.

Also for the sake of trial would you hardcode a pageNumber in the GetMultiAsDataTable() call?

Posts: 24
Joined: 24-Jan-2005
# Posted on: 29-Jun-2007 12:35:05   

Hi Thanks for taking the time to help.

I've downloaded the latest releases. The versions now are:

SD.LLBLGen.Pro.DQE.SqlServer.NET11.dll 1.0.20051.060516 SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll 1.20051.07.0307

From the latest download of the runtime libraries.

I tried hard coding the page number but I get the same result as before.

How do I get the trace of the query generated except for using the sql profiler?

Mike

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 29-Jun-2007 15:07:40   

How do I get the trace of the query generated except for using the sql profiler?

By enabling tracing in the config file. Check the manual's section "Using the generated code -> Troubleshooting and debugging"

Posts: 24
Joined: 24-Jan-2005
# Posted on: 02-Jul-2007 11:37:20   

Thanks Walaa,

I've been very very silly. Thanks for your help; i think it was my fault!

Cheers, Mike