[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

query.Skip not working

Posted on 2011-09-09
4
Medium Priority
?
246 Views
Last Modified: 2012-05-12
I have the code below to page a gridview but the query.skip doesn't work.

query.take works but qery.skip doesn't work

It always returns the first 5 rows of the datatable

Thanks,




Gridview

<asp:GridView Width="100%" ID="gvwData" CssClass="datatable" PageSize="5" runat="server"
            PagerSettings-Visible="true" >
</asp:GridView>


Code behind

Imports System.Linq.Dynamic

    Sub bindGrid()
        'bind grid data
        With Me.gvwData
            .Width = WebControls.Unit.Percentage(100)
            .EnableViewState = False
            .AutoGenerateColumns = False
            .DataSource = Me.GetFilteredData()
            .DataBind()
        End With
    End Sub

    Private Function GetFilteredData() As DataTable
        Dim dtFilterData As New DataTable
        'dynamic query against datatable 
        'select everything from currentdataset
        Dim query = From dv In Me.CurrentDataTable Select dv
        If Me.PageSize = -1 Then
            dtFilterData = query.CopyToDataTable
        Else
            'Skip the first (Me.CurrentPageIndex * Me.PageSize) records and take the next (pagezise)
            ' dtFilterData = query.Take(Me.PageSize).CopyToDataTable
            dtFilterData = query.Skip(Me.CurrentPageIndex * Me.PageSize).Take(Me.PageSize).CopyToDataTable
        End If
        Return dtFilterData
    End Function

Open in new window

0
Comment
Question by:melinalt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 18

Expert Comment

by:dj_alik
ID: 36515357
did you have primary in datatable?

and
Me.CurrentPageIndex  was changed?

and did you debug your code and watch dtFilterData?

0
 
LVL 1

Accepted Solution

by:
melinalt earned 0 total points
ID: 36527187
Never mind.. it was me all the time.

In my itemdatabound subroutine I kept using  Me.CurrentDataTable, which was the original datatable,  instead of dtFilterData.

Of course I was always displaying the same rows.. duh...

Thanks any way.

0
 
LVL 1

Author Closing Comment

by:melinalt
ID: 36553565
using new filter datatable instead.  everything works now.
0
 
LVL 1

Author Comment

by:melinalt
ID: 36550410
solved
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question