Click here to Skip to main content
Click here to Skip to main content

Advanced Paging GridView with ASP.NET 2.0/3.5

, 7 Nov 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
Advanced paging GridView with ASP.NET 2.0/3.5

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:

<%@ 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)

Share

About the Author

WizardWu
Web Developer
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 Pinmemberboodi_8120-Jan-12 1:19 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 7 Nov 2008
Article Copyright 2008 by WizardWu
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid