ASP.NET 2.0 Server Side PAging Sample

Posts   
 
    
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 01-Mar-2007 15:14:13   

I cannot find a working sample or thread on how to implement server side paging w/ a LllblGenProDataSource2 control where LivePersistence == false.

All I want to do is create a grid view bound to a data source control and fetch 5 records at a time.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 01-Mar-2007 15:45:27   

Set the AllowPaging="True" and PageSiz="xx" for the GridView. And if you set LivePersistence="false", then you should handle the PerformGetDbCount event. This event is raised when the LLBLGenProDataSource(2) control needs to retrieve the number of items in the complete resultset. This event is raised when server side paging is enabled and the total number of items in the resultset is required by the bound control(s).

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 01-Mar-2007 16:27:16   

Thanks for the help.

Here is what I did when you were writing your reply:

Code Behind:


    protected void ApplicantDataSource_PerformSelect(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2 e)
    {

        ApplicantDataSource.EntityCollection = MyApplicantEntity.FetchApplicants(e.PageNumber, e.PageSize);
        ApplicantDataSource.DataBind();
    }
    protected void ApplicantDataSource_PerformGetDbCount(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformGetDbCountEventArgs2 e)
    {
        e.DbCount = MyApplicantEntity.DbCount();
    }


HTML Code:


    <llblgenpro:LLBLGenProDataSource2 ID="ApplicantDataSource" runat="server" DataContainerType="EntityCollection" EnablePaging="True" 
        EntityFactoryTypeName="Fadv.Ehv2.BusinessLibrary.FactoryClasses.MyApplicantEntityFactory, Fadv.Ehv2.BusinessLibrary" 
        LivePersistence="False" OnPerformSelect="ApplicantDataSource_PerformSelect" 
        OnPerformGetDbCount="ApplicantDataSource_PerformGetDbCount">
    </llblgenpro:LLBLGenProDataSource2>
    
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="ApplId" DataSourceID="ApplicantDataSource" PageSize="25">
        <Columns>
            <asp:BoundField DataField="ApplId" HeaderText="ApplId" ReadOnly="True" SortExpression="ApplId" />
            <asp:BoundField DataField="LName" HeaderText="LName" SortExpression="LName" />
            <asp:BoundField DataField="FName" HeaderText="FName" SortExpression="FName" />
            <asp:BoundField DataField="Dob" HeaderText="Dob" SortExpression="Dob" />
            <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
            <asp:BoundField DataField="SsnPlainText" HeaderText="SsnPlainText" SortExpression="SsnPlainText" />
        </Columns>
    </asp:GridView>


I am assuming that in the PerformSelect method that I can call ApplicantDataSource.SelectParameters.Add() to add values into the SelectParameters collection. Then I am also assuming that I can then pass ApplicantDataSource.FilterToUse into my FetchMethod to perform programatic filtering on the fly. Are these assumptions correct?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Mar-2007 07:17:24   

I am assuming that in the PerformSelect method that I can call ApplicantDataSource.SelectParameters.Add() to add values into the SelectParameters collection. Then I am also assuming that I can then pass ApplicantDataSource.FilterToUse into my FetchMethod to perform programatic filtering on the fly. Are these assumptions correct?

Since you are the one doing the fetch (LivePersistence=false) why don't you pass the filter to the fetch method?

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 02-Mar-2007 16:06:18   

Good point.

Thanks again for the help and guidance.