Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends
i have a datagridview that retreive information from a db. My db has a table that has a column called income, now what i want is a way to sum up the value of the income column at the end of everyday to get the total income for that day. Please i need help on this thanks in advance
Posted

C#
put a textbox in the footer control then find the textbox control using

textbox txtSum= gridview1.FooterRow.FindControl("txtTotal") as TextBox

Then bind the total value to txtSum like how you will bind data to grid

txtSum= "select sum(income) from incometable" 
 
Share this answer
 
I am not sure if this is the right answer, tho you can use two controls to achieve what you want.

Use a Repeater which gets the unique days and then put the GridView inside that repeater.

Use the footer of the GridView to show the Sum of Income column.


<asp:Repeater> <!-- Get unique days -->
 <ItemTemplate>
  <asp:GridView> <!-- Bind the data based on the day -->
 </ItemTemplate>
</asp:Repeater>
 
Share this answer
 
v2

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