.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

LINQ to SQL Paging using GridView in C# and ASP.NET 3.5

Posted By: Rahul     Posted Date: November 14, 2009    Points: 2   Category :ASP.Net
This tutorial will show you how we can extend the LINQ to SQL Class and create methods that will allow us to page data from a SQL database. C# version.

View Complete Post

More Related Resource Links

custom linq to sql statement gridview paging


Ok, I know this cant really be that hard, but im having trouble finding any info. I have a gridview on the page that i am filling with data based on a user selected date range(a dropdown list). When the user clicks the button i fill the gridview and display it. This is all done using Linq to Sql. I need to impliment paging and sorting as well. Help PLEASE!!! Below is my button click event... i am open to any suggestions to get this working


protected void btnGenerate_Click(object sender, EventArgs e)
        int dateRange =0;
        if (rbDateList.Checked)
            switch (ddlDateRange.SelectedIndex)
                case 0:
                    dateRange = 30;

AJAX GridView Paging and Sorting using C# in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

GridView Paging Using Ajax in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

Advanced Paging GridView with ASP.NET 2.0/3.5

This is an article about advanced paging GridView with ASP.NET 2.0/3.5. All the HTML, CSS, JavaScript it needs have been embedded into the WizardGridView.dll.

GridView Sorting/Paging : 'REAL' AJAX with Asp.Net Series

This is a continuation of my 'REAL' AJAX with Asp.Net (not Asp.Net AJAX) series posts for those of us trying to stop relying on Asp.Net 'AJAX'.

Ok, nothing too dramatic to start things off, we are going to make some tabled data sortable and pagable all without using a bit of postback. Not only that, but it is going to be incredibly easy!

Manually sorting and paging Gridview without using datasource control

Many a times while working with Gridview we want to work with the paging and sorting functionality without using any datasource control. Gridview is flexible enough to perform these tasks without the use of any datasource control and only a few lines of code.

Optimized Paging and Sorting in ASP.NET GridView

In this article I am going to demonstrate what are the performance drawbacks of using conventional way to page and sort your GridView and then I will demonstrate 'An Optimized way to implement Paging and Sorting'.

LINQ with GridView and edit fields


My project includes a grid view which displays information of inventory items (Assets), data is quried from AssetTable. The GridView has a command field to allow editing, below is a description of the tables and how data is displayed


BuildingTable: (BuildingID, BuildingName)

AssetTable: (BuildingID,..,....,....)


ItemTemplate: Using a LINQ query I join the two table and displays in a label control a string which includes BuildingID and BuildingName (5 North Building)

 EditItemTemplate: Using a LINQ query I populate a DropDownList with strings of BuildingID and BuildingName same as above.
Here  issue which I need to resolve:
1.  ItemTemplate display the correct information (BuildingID BuildingName) but when I switch to EditItemTemplate the pair that is 
displayed is the first one on the list, how do I make is scroll to the item which was displayed in the label ?
<asp:CommandField ShowEditButton="True" >
                    <ControlStyle Wi

GridView Paging + Unsupported overload used for query operator 'Distinct'


The issue is two fold in my ASP.NET Web Application. I need to use a custom Distinct() via LINQ to SQL, and then assign thevar as a DataSource to a GridView. If I use the custom Distinct that implements IEqualityComparer, I get "Unsupported overload used for query operator 'Distinct'" exception. but if i somehow get past this, i get "The data source does not support server-side data paging" exception on GridView.DataBind(). here is the code:

distinct_employees =
    (from emp in wsq.LIT_Active_Employees
    where (String.IsNullOrEmpty(ssFirstName.Text) ? (emp.FIRST_NAME == null || emp.FIRST_NAME.StartsWith(String.Empty)) : emp.FIRST_NAME.Contains(ssFirstName.Text)) &&
            (String.IsNullOrEmpty(ssLastName.Text) ? (emp.LAST_NAME == null || emp.LAST_NAME.StartsWith(String.Empty)) : emp.LAST_NAME.Contains(ssLastName.Text)) &&a

Master-Detail GridView in Single Page example with paging throws error

___http://www.java2s.com/Code/ASP/Data-Binding/MasterDetailGridViewinSinglePage.htmI followed example at the link above.When I enablind paging=true (by pagesize=3).and clicking to pages 2|3|4 etc and so;error occuringIndex was out of range. Must be non-negative and less than the size of the collection.at cs line :sourceProducts.SelectParameters[0].DefaultValue = gridMaster.DataKeys[e.Row.DataItemIndex].Value.ToString();got any idea?what should I make to fix this ? is this error  fixable ?thanks much.

Customized Paging for gridview

Hi Allam using vs 2005 and sqlserver 2005.in my database table (name : users) there are more than 10 lac records.i have to display the user details in a grid.if i wrote the sql query as " select * from users" then it is throwing the "System.OutOfMemoryException"So i wrote the query using rownumber (i mean first it will get inly specified no of records  ex:25 )so it is displaying only that  25 recordshow to give paging in this situation...?my requirement is  in the grid i want to get  and display first 25 records  with the paging as First   Previous  1 2 3 4 5 6 7 8 9 10  Next  Last How to do this..?please help meThanks in advance,Nikhil

GridView Paging Postback

I have to DataGrids on same page and they both got paging on that cause postback. Now on every single post back i want to find which DataGrid Paging caused the post back this time... Any Ideas?

keep values in textbox in gridview whilst paging

Hi,   I have a gridview in my webpage which has paging enabled. There are around 5 textboxes in a row and when I enter some text and then move to another page and move back to the page I entered the values in, they are not lost. I have enabled the viewstate in the gridview. I have implemented a datatable to my grid which should hold the values in the viewstate. This worked before I added paging. Please can someone offer some advice as to how I can maintain the values in textboxes whilst moving between different pages? I have tried searching it but I can't seem to find any relevant info.   Thank you very much.

Gridview Objectdatasource calling funtion while paging

Hi,I am asking this question in bit confused state..I have a Gridview in a page which is bind to function via ObjectDataSource. Function returns dataset. I am returning dataset becuase its disconnected...but when navigating/ or using paging the see a call to the function again.. why is that? if dataset already has data then why it needs to go and make a call to DB again? please explainThanks

Gridview with pageddatasource paging.

Hi Friends,The code like,        con.Open();        da = new SqlDataAdapter("select *from Student", con);        da.Fill(dt);        dv = dt.DefaultView;obj.DataSource = dt.DefaultView;        obj.AllowPaging = true;        obj.PageSize = 5;        obj.VirtualCount = 5;        obj.CurrentPageIndex = 0;        obj.AllowServerPaging = false;        obj.AllowCustomPaging = true;        GridView2.DataSource = obj;           GridView2.DataBind();        con.Dispose();Data bounded in gridview very well.. but not to show paging option. how to show the paging option like 1 2 3 within gridview control.if possible , then give solution for me immediately.

GridView - LINQ

Hello.I have a GridView using LINQ and I need to do pagination and sorting.Please advice.Thank you very much.

Problem with gridview paging

HI I have problem in Gridview paging, i am using pagersettings.firstpageimageurl to set the image, if i do like this the page will call twice all its event, and if i remove this image, the page will work correctly. if anybuddy know why its so, please replay <   pagersettings mode="NextPreviousFirstLast"   firstpageimageurl="Images/nav_first.gif"   firstpagetext="First Page"   lastpageimageurl="Images/nav_last.gif"   lastpagetext="Last Page"   nextpageimageurl="Images/nav_next.gif"   nextpagetext="Next Page"   previouspageimageurl="Images/nav_previous.gif"   previouspagetext="Previous Page"   position="Bottom"/>
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend