.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

Manually sorting and paging Gridview without using datasource control

Posted By: Venkat     Posted Date: April 07, 2010    Points: 2   Category :ASP.Net
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.

View Complete Post

More Related Resource Links

How to implement paging and sorting in asp.net Gridview control?

In this article, I will explore how to implement paging and sorting in gridview control without using sql and object data sources.

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 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!

Sorting Data in a GridView Web Server Control

The GridView control provides built-in sorting functionality without requiring any coding. You can further customize the sort functionality of the GridView control by using custom SortExpression property values for columns as well as by using the Sorting and Sorted events

Sorting GridView Columns Manually

We all know that GridView columns can be sorted automatically when SQLDataSource is being used. But what if you are not using SqlDataSource to populate the GridView. Sorting the GridView manually is pretty straight forward task take a look at the code below

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'.

GridView Sorting manually

I have searched high and low - and used many solutions to no avail.  I am trying to get my data to sort, but clicking on the headings seems to do nothing at all.  Code is below:GridView control:<asp:GridView ID="GridView1" OnSorting="GridView1_Sorting"                  OnPageIndexChanging="GridView1_PageIndexChanging" runat="server" AllowPaging="True"              AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"              DataKeyNames="CiID" GridLines="None"                  onselectedindexchanged="GridView1_SelectedIndexChanged1" ForeColor="#333333"                  style="font-size: small; font-family: Tahoma"                  PagerSettings-Mode="NextPreviousFirstLast" ShowFooter="True"              Width="100%" > <PagerSettings Mode="NextPreviousFirstLast"></PagerSettings>             <RowStyle BackColor="

Gridview cancel,sorting,paging


Please can you give me the code for gridview sorting,paging and cancel and please also explain methe code for each line.....otherwise i wont understand the code

Sorting Issue in Gridview with Datasource



am having trouble figuring this one out.

Am using stored procedure and using databind for the gridview . i got the codes off other sites. I'm guessing its the code that i've underlined,
how or what do i use as the datasource for the sorting event. I used the Session for the paging event and that works but not for sorting.
any help would be appreciated.

 protected void LoadComplaint()

            gvComReport.DataSource = CompTypeStatusBLL.GetComplaint(ddlStatus.SelectedValue, ddlType.SelectedValue);
            Session["MyDataSet"] = gvComReport.DataSource;


 protected void gvComReport_Sorting(object sender, GridViewSortEventArgs e)
            DataTable dtSortTable = Session["MyDataset"] as DataTable;

            if (dtSortTable != null)
                DataView dvSortedView = new DataView(dtSortTable);
                dvSortedView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);

                gvComReport.DataSource = dvSortedView;

 private string ConvertSortDirectionToSql(SortDirection sortDirection)
            string newSortDirection = St

Any Paging, Sorting Gridview solution out there that will fit my needs????????????


Hi all,

I have found and tested many samples out there and later realized they were not working because my Gridview is actually binding to a DataTable.
The reason for that is that before binding it I am adding extra columns in my DataTable.

I am looking for a good sample code which will show me how to show a Gridview with Sorting and Paging features. I know that can easily be done with SqlDataSource, ObjectDataSrouce or even LINQ to SQL but since I am modifying the Table structure on the fly I am not sure how to implement Paging and Sorting in this situation.

Here is part of my code:

		//Load New values from table
		DataTable dtNewRecords = FillDataGridView_JobHistory(dateBegin, dateEnd, jobName, clientName);

		if ( dtNewRecords != null )
			//Finally bind the gridview
			GridView2.DataSource = dtNewRecords;

			//Sort by the selected column
			dtNewRecords.DefaultView.Sort = (String)ViewState["SortExpression"] + " " + (String)ViewState["SortDirection"];

Thank you!

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

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.

Sorting Gridview using Jquery with ASP.NET

I want to show how to sorting a gridview using a Jquery in ASP.NET, it is a flexible client-side table sorting. We have known that Jquery is a new kind of Javascript Library. You can find detail of Jquery in this site http://jquery.com/ there are lot of example with documentation and also allow free download a latest version.

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

In-Depth look at the GridView Control

In the last article we looked at few of the new controls available in Asp.net 2.0. We also talked about Grid View Control which has replaced the Asp.net 1.1 DataGrid control for good. In this article we will examine more features of the Grid View control. In this article we will see some of the common operations that can be performed using the GridView control. Apart from these operations there are many more functions that can be performed on the control and which we will see in the later articles

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.

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

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.
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