Click here to Skip to main content
11,711,009 members (85,985 online)
Click here to Skip to main content
Add your own
alternative version

Implementing Cumulative total and Select All functionality with Events in ASP.NET GridView

, 17 Dec 2012 CPOL 17.1K 658 12
There are many scenarios in which the data can be bound in a Gridview, in which various operation other than provided by default by gridview needs to be implemented. In this article we will try to bind such operations with some more features.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>Events of Gridview</title>
    <form id="form1" runat="server">
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                ForeColor="#333333" GridLines="None" ShowFooter="True" AllowPaging="True" DataKeyNames="id"
                OnPageIndexChanging="GridView1_PageIndexChanging" OnRowCancelingEdit="GridView1_RowCancelingEdit"
                OnRowEditing="GridView1_RowEditing" OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting"
                <RowStyle BackColor="#EFF3FB" />
                            <asp:CheckBox ID="chekSelect" runat="server" Checked='<%# Bind("selectedItem") %>' />
                            <asp:CheckBox ID="chekSelectALL" runat="server" Text="Select All" AutoPostBack="True"
                                OnCheckedChanged="chekSelectALL_CheckedChanged" />
                    <asp:BoundField DataField="sno" HeaderText="SNo" ReadOnly="True" />
                    <asp:TemplateField HeaderText="Name">
                            <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("uname") %>'></asp:TextBox>
                            <asp:Label ID="lblName" runat="server" Text='<%# Bind("uname") %>'></asp:Label>
                            <asp:Label ID="lblGrandTotalTxt" runat="server" Text="Grand Total"></asp:Label>
                    <asp:TemplateField HeaderText="Marks">
                            <asp:TextBox ID="txtTotalMarks" runat="server" Text='<%# Bind("totalMarks") %>'></asp:TextBox>
                            <asp:Label ID="lblTotalMarks" runat="server" Text='<%# Bind("totalMarks") %>'></asp:Label>
                            <asp:Label ID="lblGrandTotal" runat="server" Text=""></asp:Label>
                    <asp:CommandField ShowEditButton="True" />
                    <asp:CommandField ShowDeleteButton="True" />
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#2461BF" />
                <AlternatingRowStyle BackColor="White" />

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

Software Developer
India India
I am a Software Engineer from Bhopal. I started my Career from Programming in ASP and now working as a Web Developer in ASP.Net (C#). I Love coding and always ready to gain new thing and always been towards Microsoft Technologies. Apart from coding my other hobbies are traveling, Internet Surfing, spending time with family and hang out with friends.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150819.1 | Last Updated 17 Dec 2012
Article Copyright 2012 by AshishChaudha
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid