Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call function from datagrid footer to output sum (amount)

Status
Not open for further replies.

ehx6

IS-IT--Management
May 20, 2004
150
US
hi,I have created a datagrid that shows some rows. One of the columns is called amount, I want to be able to call afunction from the from the datagrid to sum (amount) and put the result in the footer. here what I have done,

I put the following in the Template column
<FooterTemplate>
<# CalTotal(DataBinder.Eval(Container.DataItem, ))%>
</FooterTemplate>

I then created a function like
Public Function CalTotal()
'I guess here where I should write the code to sum the amount field, but how?
End Function

I appreciate your help, I am not even know if I am in the right track?
thanks
EHx
 
Hi,

You could use the ItemDataBound event of the grid to calculate the total, and use that field in the footer.

Basically, the ItemDataBound event fires for every row that is added to the grid, including the header and the footer. So you will also want to check the item type (e.Item.ItemType ="Footer", etc - i think), and add the value from each row to a variable

HTH

amit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top