Skip and Take in Linq to Sql in C#

By bryan tugade

This Topic will show you on how to skip and take rows using Linq to Sql in C#.

using System;
using System.Linq;
using System.Web;
using System.Data;

public partial class Default3 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

private void GetData(int iSkip, int itake)
var sqldatacontext = new linqtosqlclassDataContext();

var data = (from p in sqldatacontext.Products where p.Color == "Black" select new { p.ProductID, p.ProductNumber, p.Name }).Skip(iSkip).Take(itake);

DataSource = data;



That's it! Happy Coding.

Related FAQs

In C#, we can select and deselect checkbox in gridview in onPostback event of checkbox in gridview header.
We can select multiple fields in a given database tables using Linq to sql. I use AdventureWorks as my database in this sample app and to show you how it works i bind the results in gridview control.
We can hover on gridview row using javascript onmouseover event. We can also change the color in code behind.
We can filter data using dataview.
We can easily bind gridview using linq to sql. Assuming that your using AdventureWorks as your database.
We could get specific rows in the database table by skip and take using Linq to Sql. Here is the sample code.
Skip and Take in Linq to Sql in C#  (1649 Views)