Click here to Skip to main content
15,867,453 members
Articles / Web Development / ASP.NET
Article

Advanced Paging GridView with ASP.NET 2.0/3.5

Rate me:
Please Sign up or sign in to vote.
3.68/5 (13 votes)
7 Nov 2008CPOL 93.9K   2.3K   49   11
Advanced paging GridView with ASP.NET 2.0/3.5

Image 1

Figure 1: The screen of ASP.NET 2.0 demo website

080925_2.JPG

Figure 2: The five extra new properties of WizardGridView

Introduction

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.

Background

Except advanced paging functionality of this GridView control, you know, when you create a new class that inherits from GridView class, the IntelliSense function inside of "Columns" tag will become invalid (see the code below). So I create two new classes - WizardTemplateField, WizardBoundField, directly inherit from Microsoft native TemplateField class and BoundField class and replace them in this WizardGridView control, and embedded into the WizardGridView.dll. Therefore, when you use this WizardGridView control in your ASPX page, the IntelliSense inside of "Columns" tag will become effective again.

Using the Code

Using this control in your ASP.NET project is so easy, like this:

ASP.NET
<%@ Register Assembly="WizardGridView" Namespace="WizardGridView" TagPrefix="Wizard" %>

<Wizard:WizardGridView ID="WizardGridView1" runat="server" 
	AllowPaging="True" AllowSorting="True"
    AutoGenerateColumns="False" DataKeyNames="OrderID" DataSourceID="SqlDataSource1"
    WizardCustomPager="True">
    <Columns>
        <asp:BoundField DataField="OrderID" HeaderText="OrderID" 
			InsertVisible="False" ReadOnly="True"
            SortExpression="OrderID" />
        <asp:BoundField DataField="CustomerID" 
		HeaderText="CustomerID" SortExpression="CustomerID" />
        <asp:BoundField DataField="OrderDate" 
		HeaderText="OrderDate" SortExpression="OrderDate" />
        <asp:BoundField DataField="ShipName" 
		HeaderText="ShipName" SortExpression="ShipName" />
        <asp:BoundField DataField="ShipCity" 
		HeaderText="ShipCity" SortExpression="ShipCity" />
    </Columns>
</Wizard:WizardGridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
		ConnectionString="<%$ ConnectionStrings:ConnString_SqlClient %>"
    SelectCommand="SELECT [OrderID], [CustomerID], [OrderDate], 
		[ShipName], [ShipCity] FROM [Orders]">
</asp:SqlDataSource>
        

or with IntelliSense like this:

<Wizard:WizardGridView ID="WizardGridView1" runat="server" 
		AllowPaging="True" AllowSorting="True"
    AutoGenerateColumns="False" DataKeyNames="OrderID" DataSourceID="SqlDataSource1"
    WizardCustomPager="True">
    <Columns>
        <asp:WizardBoundField DataField="OrderID" 
		HeaderText="OrderID" InsertVisible="False" ReadOnly="True"
            SortExpression="OrderID" />
        <asp:WizardTemplateField ... />

History

  • 25th September, 2008 - Original posting, version 1.0, five new properties of this control have been added. You can find them in Visual Studio 2005/2008 "Property" window.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Taiwan Taiwan
A young programmer in Taipei City, Taiwan. Earn little money and just coding for fun.

Comments and Discussions

 
QuestionIssue in the next and previous navigation Pin
boodi_8120-Jan-12 1:19
boodi_8120-Jan-12 1:19 
GeneralRow_command does not fire Pin
ebot6424-Feb-11 3:18
ebot6424-Feb-11 3:18 
GeneralMy vote of 5 Pin
ROHANCV30-Aug-10 20:09
ROHANCV30-Aug-10 20:09 
GeneralMy vote of 3 Pin
ROHANCV30-Aug-10 20:08
ROHANCV30-Aug-10 20:08 
Questionhow can use command argument in this component ? Pin
maziyar21-Aug-10 11:05
maziyar21-Aug-10 11:05 
Rantuse english or how to install your language Pin
noname-201321-Nov-08 9:09
noname-201321-Nov-08 9:09 
e-em... not sure how to read your comments
Can you add english comments also? 'cause reading code without author comments equal to make a puzZzle

regards
Generalif any problem, please tell us Pin
WizardWu24-Sep-08 20:21
WizardWu24-Sep-08 20:21 
GeneralRe: if any problem, please tell us Pin
SupermanDT1-Oct-08 2:04
SupermanDT1-Oct-08 2:04 
GeneralRe: if any problem, please tell us Pin
WizardWu5-Oct-08 1:03
WizardWu5-Oct-08 1:03 
GeneralRe: if any problem, please tell us Pin
mishraloke15-Aug-10 5:29
mishraloke15-Aug-10 5:29 
GeneralRe: if any problem, please tell us Pin
WizardWu16-Aug-10 5:02
WizardWu16-Aug-10 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.