Click here to Skip to main content
15,902,275 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Table name collection
Sr. No.	Name	Amount
1	Mahima	45
2	Aman	56
3	Raj	78

i want to get total of Amount column at the top of .aspx's page output can you explain me how write coding in aspx.cs page can you help me for coding ???
Updated 13-Jun-15 2:13am
[no name] 9-Jun-15 14:29pm    
What answer did you get the last time you asked?
Maciej Los 9-Jun-15 16:10pm    
What have you tried? Where are you stuck?
Mostafa Asaduzzaman 9-Jun-15 17:37pm    
Is it a simple table or gridview?

Share this answer
Mahima Singh 10-Jun-15 11:50am    
Dear I want to display total of column on Label. Kindly help for coding
Maciej Los 10-Jun-15 11:51am    
See my comments to solution 2.
Mahima Singh 13-Jun-15 8:16am    
it is not working dear.
NOTE: If you are use System.Data.DataTable then you can use this solution

decimal total = 0;
          for(int i=0;i            {
              total += Convert.ToDecimal(dt.Rows[i][2]);
          txtTotal.Text = total.ToString();

In the aspx page define this:
<p><asp:label text="Total Amount : " runat="server" xmlns:asp="#unknown"></asp:label><asp:textbox id="txtTotal" runat="server" enabled="false" xmlns:asp="#unknown"></asp:textbox></p>

Wrap the calculation in Page_Load or the other method to display data.

Hope this will help.
Share this answer
Maciej Los 9-Jun-15 18:26pm    
Why don't you recommend to use ComputeColumn (DataTable), such as result = dt.Compute("Sum(Amount)","")?
See: How to calculate the sum of the datatable column in
Mostafa Asaduzzaman 9-Jun-15 18:29pm    
thanks for that

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900