Technical Training
ASP.NET 2.0Table of Contents
ASP.NET Adding Sorting and Paging in GridView
ASP.NET 2.0 - Event handler for Sorting Event
ASP.NET 2.0 - GridView Control DataASP.NET Adding Sorting and Paging in GridView
Adding Sorting and Paging in GridView
In this tutorial you will learn adding sorting and paging in a GridView Control, Implement Two Column Sorting, Create Code for Custom Sorting, Editing the GridView control data, Deleting Displayed Records, Inserting Records and Using Templates.
Adding Sorting and Paging
Sorting and paging can be added to the GridView control without writing any code.
1. In Design view, right-click the GridView control, and then click Show Smart Tag.
2. On the GridView Tasks menu, select the Enable Sorting box.
3. The column headings in the GridView control change to links.
4. On the GridView Tasks menu, select the Enable Paging box.
5. A footer is added to the GridView control with page number links.
6. Optionally, use the Properties window to change the value of the PageSize property from 10 to a smaller page size.
7. Press CTRL+F5 to run the page.
8. The GridView control is displayed with StudentID, StudentName, StudentAge and CourseId columns. The column headings can be clicked to sort by the contents of that column.

9. Close the browser.
Implementing Two Column Sorting
At this point, the contents of the table can be sorted on the basis of a single column. However, there may be situations where the developer needs to provide an interface to sort data on the basis of two or more columns. To implement two-column sorting, custom sorting features may be added. In this section, let us add a DropDownList control to specify a second column to sort the grid. The DropDownList control will display the names of columns from the StudentMaster table that users can sort by.
1. In the Default.aspx page, switch to Design view.
2. In the Toolbox, from the Standard group, drag a DropDownList control onto the page.
3. Right-click the DropDownList control, click Show Smart Tag, and then on the Common DropDownList Tasks menu, click Edit Items.

4. In the ListItem Collection Editor dialog box, click Add, and set Text and Value to StudentName.
5. Click Add to add another list item, and then set Text and Value to CourseId.
6. Click Add, and then set Text and Value to StudentAge.
7. Click Add, and then set Text and Value to StudentId.

8. Set Selected to True.
9. Click OK.
10. On the Common DropDownList Tasks menu, select the Enable AutoPostBack box.

11. In the Toolbox, from the Standard group, drag a Label control onto the page.
12. Right-click the Label control, click Properties, and then set ID to LabelSortDisplay.
Creating Code for Custom Sorting
For custom sorting, we now write an event handler for the GridView control's Sorting event. The Sorting event is raised when the user clicks a column heading in the GridView control.
ASP.NET 2.0
- Getting started with ASP.NET 2.0
- .NET Framework Fundamentals
- Microsoft.NET Framework Tools
- Application Development in .NET
- What's New in the .NET Framework 2.0 ?
- Introduction to Visual Studio.NET
- Installing Visual Studio.NET 2005
- Working with Visual Studio.NET Web Applications
- Whats New in ASP.NET 2.0
- Creating an ASP.NET Application
- ASP.NET Code Directory
- ASP.NET Page Object Model
- ASP.NET Server Controls
- ASP.NET Working With Master Pages
- ASP.NET Creating Content for Master Page
- ASP.NET Referencing Master Page Members
- ASP.NET Changing Master Pages Dynamically
- ASP.NET Creating Nested Master Pages
- ASP.NET Working with Web Parts
- ASP.NET Using Web Parts and Controls in Web Pages
- ASP.NET Web Pages and Layout
- ASP.NET - Adding Web Parts at Run Time
- ASP.NET Personalization: User Profiles and Themes
- ASP.NET Data Access features
- ASP.NET State Management
- ASP.NET Customizing the Session State Mechanism
- ASP.NET State Management And Caching
- ASP.NET Security
- Forms Authentication in ASP.NET
- ASP.NET Managing Membership and Roles
- ASP.NET Configuring Page-Level Caching
- ASP.NET Setting Application-Level Caching
- ASP.NET Data Source Object Model
- ASP.NET SqlDataSource Control
- ASP.NET Data Bound Controls
- ASP.NET GridView Control
- ASP.NET GridView Filtering
- ASP.NET Adding Sorting and Paging in GridView
- ASP.NET DataBound Controls - Details View
- ASP.NET Using a Grid to Display Detail Information
- ASP.NET Displaying Master-Detail Data on the Same Page
- Displaying Master-Detail Data on Separate Pages in ASP.NET
- ASP.NET Creating Web Wizards
- ASP.NET : Dynamic Image control
- ASP.NET Advanced Site Functionality







