well Amitabh, I assume you want to know about how to calculate sum of total amount when we select particular column in gridview.
Here is simple code
ASPX
<%@ page language="VB" masterpagefile="~/MasterPages/ Defau lt.master" autoeventwireup="false"
codef ile= "AddRunningTotal.aspx.vb" inherits="GridView_AddRunningT otal" title="GridView: Add Running Total" %>
<asp:content id="Content1" contentplaceholderid="ContentP laceH older1" runat="Server">
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="false" showfooter="true">
<columns>
<asp:templatefield headertext="Number">
<itemtem p late>
<%# AddNumberToTotal(Container.Dat aItem ) %>
</itemtemplate>
<foote rstyle font-bold="true" />
<footertemplate>
<%# Total %>
</footertemplate>
</asp :templatefield>
</columns>
< /a sp:gridview>
</asp:content>
COD E-BEHIND
Partial Class GridView_AddRunningTotal
Inhe rits System.Web.UI.Page
Private _total As Integer
Protected Property Total() As Integer
Get
Return _total
End Get
Set(ByVal value As Integer)
_total = value
End Set
End Property
Protected Function AddNumberToTotal(ByVal obj As Object) As Integer
Dim number As Integer = Convert.ToInt32(obj)
Me.Total += number
Return number
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim numbers() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
GridView1.DataSource = numbers
GridView1.DataBind()
End If
End Sub
End Class
For more details , Please visit the source site :
http://forums.asp.net/t/1 22361 0.aspx
Answered by
Romi
, an ibibo Master,
at
6:17 PM on June 17, 2008