'______________________________________________________ ' LINQ 2: Using Paging ' Ron Kessler ' 2/9/09 ' _______________________________________________________ ' 'Step 1: Make sure to look at the tables I use in my Object Designer and add them. 'This form shows how to grab records 10 at a time. Partial Class Paging Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load '---get the current row from the web server querystring variable defined below Dim rowNumber As Integer = Convert.ToInt32(Request.QueryString("rowNumber")) '---the row which points to the next group of ten Dim nextTen As String = (rowNumber + 10).ToString() '---each time the page is loaded/created only show the 10 we requested HyperLink1.NavigateUrl = Request.Path & "?rowNumber=" & nextTen populateGrid(rowNumber) End Sub Protected Sub populateGrid(ByVal rowNumber As Integer) Dim dc As New AdventureWorksDataContext Dim products = From p In dc.Products _ Order By (p.ProductNumber) _ Select New With {.Product_Name = p.ProductNumber, p.Name, _ .Our_Cost = String.Format("{0:n2}", p.StandardCost)} GridView1.DataSource = products.Skip(rowNumber).Take(10) '--this skips past the current group and takes the next 10 GridView1.DataBind() End Sub End Class