Click here to Skip to main content
11,636,889 members (68,748 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Gridview Sorting using attribute [Source Code]

, 30 Aug 2013 CPOL 43.4K 400 28
Sorting GridView using attribute property of GridView
demo of my project
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        &nbsp;<asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowSorting="true"  OnSorting="gvcontent_Sorting"            Width="100px"   >
               <asp:TemplateField HeaderText="History ID" SortExpression="History_ID">
                                   <ItemTemplate><asp:Label runat="server" ID="lblRewards_Type" Text='<%# Eval("History_ID") %>' /></ItemTemplate>
                                    <HeaderStyle ForeColor="Maroon" Font-Underline="True" />
               <asp:TemplateField HeaderText="Admin id" SortExpression="admin_ID">
                                   <ItemTemplate><asp:Label runat="server" ID="lblAlias" Text='<%# Eval("admin_ID") %>' /></ItemTemplate>
                                    <HeaderStyle ForeColor="Maroon" Font-Underline="True" />
                <asp:TemplateField HeaderText="Ip address" SortExpression="Ip_address">
                                   <ItemTemplate><asp:Label runat="server" ID="dsd" Text='<%# Eval("Ip_address") %>' /></ItemTemplate>
                                    <HeaderStyle ForeColor="Maroon" Font-Underline="True" />
                <asp:TemplateField HeaderText="Mac Address" SortExpression="Mac_Address">
                                   <ItemTemplate><asp:Label runat="server" ID="dsd" Text='<%# Eval("Mac_Address") %>' /></ItemTemplate>
                                    <HeaderStyle ForeColor="Maroon" Font-Underline="True" />
                  <asp:TemplateField HeaderText="Login datetime" SortExpression="Login_datetime">
                                   <ItemTemplate><asp:Label runat="server" ID="dsd" Text='<%# Eval("Login_datetime") %>' /></ItemTemplate>
                                    <HeaderStyle ForeColor="Maroon" Font-Underline="True" />
        <asp:Label ID="lblmsg" runat="server" Text="Label" Visible="False"></asp:Label>

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.


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


About the Author

Web Developer
India India
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150728.1 | Last Updated 31 Aug 2013
Article Copyright 2013 by AJD-salute
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid