Click here to Skip to main content
15,891,316 members
Articles / Web Development / ASP.NET

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

Rate me:
Please Sign up or sign in to vote.
4.31/5 (9 votes)
8 Dec 2008CPOL3 min read 63.5K   720   28  
This article demonstrate the Sorting mechanism for Nullable datatype when used with IList collection.
<%@ 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)


Written By
Technical Lead
Australia Australia
Whatsup-->Exploring--> MVC/HTML5/Javascript & Virtualization.......!
www.santoshpoojari.blogspot.com

Comments and Discussions