Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

GridView:Sorting & Paging Using Generics And Nullable Datatype Function Of C# GetValueOrDefault()

, 8 Dec 2008 CPOL
This article demonstrate the Sorting mechanism for Nullable datatype when used with IList collection.
Sorting_And_Paging.zip
Sorting And Paging
App_Code
Image
Asc.gif
Desc.gif
Thumbs.db
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CountryView.aspx.cs" Inherits="SortingAndPaging.CountryView" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Sorting And Paging</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:GridView runat="server" ID="gridCountry" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns="False" EmptyDataText="No Data Found" PageSize="5" OnPageIndexChanging="gridCountry_PageIndexChanging"
                OnRowCreated="gridCountry_RowCreated" OnSorting="gridCountry_Sorting" BorderColor="#404040" BorderWidth="1px" BorderStyle="Solid" ForeColor="#404040">
                <Columns>
                    <asp:TemplateField HeaderText="Int:Country ID" SortExpression="CountryID">
                        <ItemTemplate>
                            <%#Eval("CountryID")%>
                            &nbsp;
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="String:Country Name" SortExpression="CountryName">
                        <ItemTemplate>
                            <%#Eval("CountryName")%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Nullable Int:Country Trade Code" SortExpression="CountryTradeCode">
                        <ItemTemplate>
                            <%#Eval("CountryTradeCode")%>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <HeaderStyle BackColor="DarkOrange" Font-Bold="True" ForeColor="White" BorderColor="DarkGray" BorderStyle="Solid" Font-Names="Arial Unicode MS" Font-Size="Small" />
                <RowStyle BorderColor="#404040" BorderStyle="Solid" Font-Names="Trebuchet MS" Font-Size="Small" />
                <AlternatingRowStyle BackColor="Bisque" BorderColor="#404040" BorderStyle="Solid"
                    BorderWidth="1px" Font-Names="Trebuchet MS" Font-Size="Small" />
            </asp:GridView>
        </div>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

santosh poojari
Technical Lead
India India
Whatsup-->Exploring--> MVC/HTML5/Javascript & Virtualization.......!
www.santoshpoojari.blogspot.com

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141216.1 | Last Updated 8 Dec 2008
Article Copyright 2008 by santosh poojari
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid