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

Advanced Paging GridView with ASP.NET 2.0/3.5

By , 7 Nov 2008
 

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)

About the Author

WizardWu
Web Developer
Taiwan Taiwan
Member
A young programmer in Taipei City, Taiwan. Earn little money and just coding for fun.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionIssue in the next and previous navigationmemberboodi_8120 Jan '12 - 1:19 
Hi,
 
Thanks for the effort and the great control i'm using it from long long time, when i came back to use it in a new project, i saw that the next and previous buttons are not working,
 
Then next is always taking me to page index 2
and the prev is always taking me to the page index 1
 
Please have you seen this issue before thanks, i reviewed the code and nothing seems to be wrong but don't know why it is not working. Thanks.
 
Best Regards,
Abdallah Nehme
GeneralRow_command does not firememberebot6424 Feb '11 - 3:18 
I wanted to implement the gridview row command on this control and its not working. How can I make it to work?? Thanks. The control is wonderful...
GeneralMy vote of 5memberROHANCV30 Aug '10 - 20:09 
Quit excellent
GeneralMy vote of 3memberROHANCV30 Aug '10 - 20:08 
Quit excellent
Questionhow can use command argument in this component ?membermaziyar21 Aug '10 - 11:05 
how can use command argument in this component ?
Rantuse english or how to install your languagememberykorotia21 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 usmemberWizardWu24 Sep '08 - 20:21 
as title,
i wrote it in Traditional Chinese VS 2005,
i'm not sure is it could run correctly in English or other language IIS & VS 2005/2008.
 
if you use this GridView in your VS 2005/2008 have any problem, please leave message here.
thanks a lot.
Smile | :)
GeneralRe: if any problem, please tell usmemberSupermanDT1 Oct '08 - 2:04 
Great control, thank you! It works fine in VS 2008 too. The only problem is your grid does not allow the auto format of the default datagrid. Can you fix that? Thanks again.
HHOtube.com
GeneralRe: if any problem, please tell usmemberWizardWu5 Oct '08 - 1:03 
thanks for your reply,
but i'm not sure how to fix it.
 
Due to the background color of 「auto format」, will be covered by my C# configuration
of OnRowDataBound function of WizardGridView.cs,
so you can't customize the background color by 「auto format」tool or other way.
 
But some UI or color properties you can still use by IntelliSense or "Property" window,
like "RowStyle-ForeColor", "BorderColor", .... etc.
GeneralRe: if any problem, please tell usmembermishraloke15 Aug '10 - 5:29 
Hi,
 
I have used your code and used it as a user control but the problem is that when i am using it in my Hosting server its not showing in the browser. Please help me Confused | :confused:
Frown | :( Frown | :(
 
Thanks & Regards
Alok

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 7 Nov 2008
Article Copyright 2008 by WizardWu
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid