Paging in asp.net

Posts   
 
    
DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 21-Feb-2007 18:59:49   

Hi all, are there any example of paging in asp.net using Selfservicing and one of the Datasource controls.. Or could anybody help me, I am not sure how to do it, and I am not having much luck.

Thanks

Jason

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Feb-2007 19:26:34   

Jason, I recommend you the Help section **Generated Code - Databinding with ASP.NET 2.0 SelfServicing **which explain that and have a simple but useful example. If not enough, you can study the full-application examples at the download area at http://www.llblgen.com.

Good luck wink

David Elizondo | LLBLGen Support Team
DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 21-Feb-2007 21:39:01   

daelmo wrote:

Jason, I recommend you the Help section **Generated Code - Databinding with ASP.NET 2.0 SelfServicing **which explain that and have a simple but useful example. If not enough, you can study the full-application examples at the download area at http://www.llblgen.com.

Good luck wink

Dam i must be going blind confused I found that and all is gooood. I love LLBL I dont use it that often as the most of the projects I am working on have their own DAL & such, but Im working on implemenitng LLB wherever i can.

Can I just make one suggetion as a user, Can we please please have a solid ASp.NET example, not the pet shop as that is confusing. I guess what I am saying is, when i read your posts...Like most other on this forum, you seem to make perfect sense and all is very understandable, but a solid .NEt example of paging, databing and comple updating would sure be great.

Thanks

Jason

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Feb-2007 21:53:07   

These threads may be interesting to you:

PetShop Discussions http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3517 http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7045&HighLight=1

and a good example of good implementation of LLBL in ASP 2.0 and template's usage and potential:

ASP.NET 2.0 GUI templates released! (beta) http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8613

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 21-Feb-2007 22:18:13   

Solid ASP.NET example? How about THIS forums software? simple_smile Http://www.llblgen.com/hnd

The admin section has examples of the datasourcecontrol.

Frans Bouma | Lead developer LLBLGen Pro
DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 22-Feb-2007 10:58:07   

Otis wrote:

Solid ASP.NET example? How about THIS forums software? simple_smile Http://www.llblgen.com/hnd

The admin section has examples of the datasourcecontrol.

Ok I see thats an awesome example.. Is there a VB example by any chance..

Also lets say i have function in my BLL like this



    Public Function GetImages(ByVal iSectionID As Integer) As DataTable
        Dim ImageTable As New GetImagesTypedView
        Dim ImageFilter As IPredicateExpression = New PredicateExpression()
        ImageFilter.Add(GetImagesFields.SectionId = iSectionID)
        ImageTable.Fill(0, Nothing, False, ImageFilter, Nothing, Nothing)
        Return ImageTable
    End Function

Is it possible to set the LLBLDatasourceControl to use that function, rather than using one of the 3 default collections type?

I saw something in the documentation but i am not sure I have got the right end of the stick.

Many thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Feb-2007 15:09:29   

To bind to a dataTable you can use ObjectDataSource.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 22-Feb-2007 16:26:11   

BUt then again, there's no use. The DataSourceControls are for 2-way databinding, i.e. you edit the data and it's updated in the bound container. When you bind a read-only object, you can also simply bind the datatable directly to the DataSource property of the grid.

Frans Bouma | Lead developer LLBLGen Pro
DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 22-Feb-2007 17:58:07   

Walaa wrote:

To bind to a dataTable you can use ObjectDataSource.

Hi, but using an object datasource means a fair amount of coding for Data paging, and having to use its own way, and it always seems to cry about not being able to find a method when the method is there all present & correct with the right signature. Now in my new method I have quite an easy time of it..


    Public Function GetImages(ByVal iSectionID As Integer, ByVal iPageNum As Integer) As ImagesCollection


        Dim i As Integer = iPageNum
        If i = 0 Then
            i = 1
        Else
            i = i + 1
        End If
        Dim ImageTable As New ImagesCollection()
        Dim ImageFilter As IPredicateExpression = New PredicateExpression()
        ImageFilter.Add(ImagesFields.SectionId = iSectionID)
        ImageTable.GetMulti(ImageFilter, 0, Nothing, Nothing, i, 12)
        Return ImageTable

    End Function


Now from what I can gather using this code and looking at the SQL Profile this is actually paging correctly and hence is doing what i wanted it to do. As the UI page is only for read only I do not need 2 way data binding so its ok. What I had not worked out was that you can set the page size in the LLBL calling code and then just pass it a page number and the rest I guess is magic wink

This works really well with a datalist as it doesnt have any paging built in, so I keep the page number in my page and then use the above function to page the data.

Not sure if its the right way, but its working...any comments would be good. I also use this function to get the total record count


    Public Function GetImageCount(ByVal iSectionID) As Integer
        Dim i As Integer
        Dim ImageTable As New ImagesCollection()
        Dim ImageFilter As IPredicateExpression = New PredicateExpression()
        ImageFilter.Add(ImagesFields.SectionId = iSectionID)
        i = ImageTable.GetDbCount(ImageFilter, Nothing)
        ImageTable = Nothing
        ImageFilter = Nothing
        Return i
    End Function

Thanks every body...and sorry If i am being silly, I'm just a bit of noob some days.

Jason

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 23-Feb-2007 10:22:25   

That's a proper way to do it simple_smile . You could also fetch the data as a dyn. list, as it's readonly anyway, but the result is the same simple_smile .

Frans Bouma | Lead developer LLBLGen Pro
DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 21-Mar-2007 02:44:08   

Otis wrote:

That's a proper way to do it simple_smile . You could also fetch the data as a dyn. list, as it's readonly anyway, but the result is the same simple_smile .

Sorry for not replying sooner. Thank for the input, Its nice to have an expert & the devs tell you you have done it right smile

Jason