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
Solved

query.Skip not working

Posted on 2011-09-09
4
241 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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