Gridview – Client side sorting and paging

The GridView control provides you with the option of sorting and paging records without requiring a form-post back to the Web server. In other words, you can re-render the contents of a GridView when sorting and paging, without needing to re-render the entire page.

You enable client paging and sorting by assigning the value true to the EnableSortingAndPagingCallback property. When this property has the value true, the GridView uses JavaScript to request an updated set of records from the Web server.


1 <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

2

3 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

4 <html>

5 <head id=”Head1″ runat=”server”>

6 <title>Callback GridView</title>

7 </head>

8 <body>

9 <form id=”Form1″ runat=”server”>

10 <%=DateTime.Now %>

11 <asp:GridView ID=”GridView1″ DataSourceID=”TitlesSource” EnableSortingAndPagingCallbacks=”true”

12 AllowPaging=”true” AllowSorting=”true” runat=”Server” />

13 <asp:SqlDataSource ID=”TitlesSource” ConnectionString=”Server=localhost;Database=northwind;Trusted_Connection=true”

14 SelectCommand=”SELECT * FROM customers” runat=”Server” />

15 </form>

16 </body>

17 </html>


Here when you will sort the page or click on the page number the time will not change as it is being set on the page load but the data will get sorted. The time doesn’t change because the page is not reloaded.

Behind the scenes, the GridView uses the Microsoft Internet Explorer XMLHTTPRequest object to communicate with the Web server. This object is supported by Internet Explorer version 5.0 and higher.

However this does not work when you have a templatefield in your Gridview. If you have a templatefield in your Gridview you need to perform the pagination like traditional way handling the events.

How to find fulfillment at work

Work can be heavenly, hellish or somewhere in between. No matter what the circumstances of your work, you can make your professional life more fulfilling. Here’s how you can do it:

– Try to broaden your vision beyond the job you perform. Find out as much about your company as you can.

– Volunteering for new and more challenging assignments as soon as they become available will help. Ask before your boss thinks of someone else.

– Ask your boss what can be done to raise the level of responsibility and creativity in your present assignment. If you want a more enriched job, ask for it. Make suggestions.

– Expand your capabilities, learn new skills. Enjoy the feeling that you can do your job as well as anyone has ever done it.

– Make use of opportunities to help coworkers succeed. Take newcomers and less experienced employees under your wing. Teach them everything you know.

– Think up ideas for doing your job better, faster and differently. This will pump you up, as will the appreciation you receive from your superiors.

– If none of the ideas above do the trick for you, and you’re determined to feel better about your vocation, start hunting for a new situation that meets your needs to grow while you work.