You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Jose Selesan <js...@gmail.com> on 2008/12/05 20:14:02 UTC

Pagination

Hi people. I'm currently working on a web page used to search products and I
need to paginate the results. I tryed using QueryForList with parameters
SkipResults and MaxResults and works great. Now, I need to know the total
results count in order to create a paginator and my question is: do I need
to invoke an extra "SELECT COUNT" query to get the total rows count? Or
there is another way to know how many records there are in total?

Thanks
Jose

RE: Pagination

Posted by "Clough, Samuel (USPC.PRG.Atlanta)" <Sa...@princetonrg.com>.
I don't know anyway other than count to get totals.  We then used an
orderby and rownum in order to get the desired records.

 

From: Jose Selesan [mailto:jselesan@gmail.com] 
Sent: Friday, December 05, 2008 2:14 PM
To: user-cs@ibatis.apache.org
Subject: Pagination

 

Hi people. I'm currently working on a web page used to search products
and I need to paginate the results. I tryed using QueryForList with
parameters SkipResults and MaxResults and works great. Now, I need to
know the total results count in order to create a paginator and my
question is: do I need to invoke an extra "SELECT COUNT" query to get
the total rows count? Or there is another way to know how many records
there are in total?

Thanks
Jose


--------------------------------------------------------------------------
Princeton Retirement Group, Inc - Important Terms
This E-mail is not intended for distribution to, or use by, any person or entity in any location where such distribution or use would be contrary to law or regulation, or which would subject Princeton Retirement Group, Inc. or any affiliate to any registration requirement within such location.
This E-mail may contain privileged or confidential information or may otherwise be protected by work product immunity or other legal rules. No confidentiality or privilege is waived or lost by any mistransmission. Access, copying or re-use of information by non-intended or non-authorized recipients is prohibited. If you are not an intended recipient of this E-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute any portion of this E-mail.
The transmission and content of this E-mail cannot be guaranteed to be secure or error-free. Therefore, we cannot represent that the information in this E-mail is complete, accurate, uncorrupted, timely or free of viruses, and Princeton Retirement Group, Inc. cannot accept any liability for E-mails that have been altered in the course of delivery. Princeton Retirement Group, Inc. reserves the right to monitor, review and retain all electronic communications, including E-mail, traveling through its networks and systems (subject to and in accordance with local laws). If any of your details are incorrect or if you no longer wish to receive mailings such as this by E-mail please contact the sender by reply E-mail.
--------------------------------------------------------------------------

RE: Pagination

Posted by "Clough, Samuel (USPC.PRG.Atlanta)" <Sa...@princetonrg.com>.
The problem here is severe performance issues for large datasets.  Thus,
he needed a count without loading the whole dataset.

-----Original Message-----
From: Juan Pablo Araya [mailto:juanpablo.araya@gmail.com] 
Sent: Monday, December 08, 2008 1:01 PM
To: user-cs@ibatis.apache.org
Subject: Re: Pagination

As far as I know, if your gridview (or whatever the control you use to
show the results) uses an object datasource that calls a method with
parameters from the textbox or the control(s) for the query, the
gridview control itself can paginate. For example:

<asp:GridView ID="GridViewName" runat="server"
DataSourceID="objectDataSource1" AllowPaging="true" PageSize="20">
.....
</asp:GridView>

<asp:ObjectDataSource ID="objectDataSource1" runat="server"
SelectMethod="TheMethod"
 TypeName="The.Namespace.For.The.Class">
<SelectParameters>

<asp:ControlParameter Name="Parameter1" ControlID="TextBoxControl1"
ConvertEmptyStringToNull="true"
                                Type="Int32" PropertyName="Text" />
<asp:ControlParameter Name="Parameter2" ControlID="DropDownListControl1"
                                Type="Int32"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>

Then, the class The.Namespace.For.The.Class must have a method like
this:

public (List<Something> or DataTable) TheMethod(int Parameter1, int
Parameter2) {
  return  ibatis call for list, or build a datatable based on the ibatis
call
}

Note the "int Parameter1", parsed through a Textbox.Text (string): the
object datasource then try to parse the text to a integer, in the same
way as the dropdownlist ... the important is that the signature of the
method is the same as the name in the controlparameters.

With this, the object datasource calls the method, fill the gridview
and do the pagination based on the results. When you click the "second
page", the object data source calls again the method and fill the GV
based on the results and the page you select. You can forget then the
count and the manual pagination.

Hope this works and sorry for my poor english!


On Fri, Dec 5, 2008 at 4:14 PM, Jose Selesan <js...@gmail.com> wrote:
> Hi people. I'm currently working on a web page used to search products
and I
> need to paginate the results. I tryed using QueryForList with
parameters
> SkipResults and MaxResults and works great. Now, I need to know the
total
> results count in order to create a paginator and my question is: do I
need
> to invoke an extra "SELECT COUNT" query to get the total rows count?
Or
> there is another way to know how many records there are in total?
>
> Thanks
> Jose
>



-- 
Juan Pablo Araya

--------------------------------------------------------------------------
Princeton Retirement Group, Inc - Important Terms
This E-mail is not intended for distribution to, or use by, any person or entity in any location where such distribution or use would be contrary to law or regulation, or which would subject Princeton Retirement Group, Inc. or any affiliate to any registration requirement within such location.
This E-mail may contain privileged or confidential information or may otherwise be protected by work product immunity or other legal rules. No confidentiality or privilege is waived or lost by any mistransmission. Access, copying or re-use of information by non-intended or non-authorized recipients is prohibited. If you are not an intended recipient of this E-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute any portion of this E-mail.
The transmission and content of this E-mail cannot be guaranteed to be secure or error-free. Therefore, we cannot represent that the information in this E-mail is complete, accurate, uncorrupted, timely or free of viruses, and Princeton Retirement Group, Inc. cannot accept any liability for E-mails that have been altered in the course of delivery. Princeton Retirement Group, Inc. reserves the right to monitor, review and retain all electronic communications, including E-mail, traveling through its networks and systems (subject to and in accordance with local laws). If any of your details are incorrect or if you no longer wish to receive mailings such as this by E-mail please contact the sender by reply E-mail.
--------------------------------------------------------------------------

Re: Pagination

Posted by Juan Pablo Araya <ju...@gmail.com>.
As far as I know, if your gridview (or whatever the control you use to
show the results) uses an object datasource that calls a method with
parameters from the textbox or the control(s) for the query, the
gridview control itself can paginate. For example:

<asp:GridView ID="GridViewName" runat="server"
DataSourceID="objectDataSource1" AllowPaging="true" PageSize="20">
.....
</asp:GridView>

<asp:ObjectDataSource ID="objectDataSource1" runat="server"
SelectMethod="TheMethod"
 TypeName="The.Namespace.For.The.Class">
<SelectParameters>

<asp:ControlParameter Name="Parameter1" ControlID="TextBoxControl1"
ConvertEmptyStringToNull="true"
                                Type="Int32" PropertyName="Text" />
<asp:ControlParameter Name="Parameter2" ControlID="DropDownListControl1"
                                Type="Int32" PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>

Then, the class The.Namespace.For.The.Class must have a method like this:

public (List<Something> or DataTable) TheMethod(int Parameter1, int
Parameter2) {
  return  ibatis call for list, or build a datatable based on the ibatis call
}

Note the "int Parameter1", parsed through a Textbox.Text (string): the
object datasource then try to parse the text to a integer, in the same
way as the dropdownlist ... the important is that the signature of the
method is the same as the name in the controlparameters.

With this, the object datasource calls the method, fill the gridview
and do the pagination based on the results. When you click the "second
page", the object data source calls again the method and fill the GV
based on the results and the page you select. You can forget then the
count and the manual pagination.

Hope this works and sorry for my poor english!


On Fri, Dec 5, 2008 at 4:14 PM, Jose Selesan <js...@gmail.com> wrote:
> Hi people. I'm currently working on a web page used to search products and I
> need to paginate the results. I tryed using QueryForList with parameters
> SkipResults and MaxResults and works great. Now, I need to know the total
> results count in order to create a paginator and my question is: do I need
> to invoke an extra "SELECT COUNT" query to get the total rows count? Or
> there is another way to know how many records there are in total?
>
> Thanks
> Jose
>



-- 
Juan Pablo Araya