Figure 1: The screen of ASP.NET 2.0 demo website
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.