Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Amount field...Grid View Footer Problem

Author  Topic 

sheena
Starting Member

45 Posts

Posted - 2007-06-08 : 17:18:04
Hello frdz,
I have a field of amount.I want to make the summary total of that amount field.

I have the
Amount field
Total Exp
50
66.75
-----------
116.75

I m not getting error with the below code but i m not getting at all a
output of total in the footer in grid-view...


<asp:GridView ID="MiscPayGridView" runat="server" ShowFooter="True">
<asp:TemplateField HeaderText=" Total Expenses">
<ItemTemplate>
<%# Eval("totalexp", "{0:c}")%>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblSummary" runat="server" />
</FooterTemplate>
</asp:TemplateField>



private decimal _TotalExpTotal = 0;

protected void MiscPayGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal TotalExps = (decimal)DataBinder.Eval(e.Row.DataItem, "totalexp");
_TotalExpTotal += TotalExps;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblSummary = (Label)e.Row.FindControl("lblSummary");
lblSummary.Text = String.Format("Total Exp: {0:c}", _TotalExpTotal);
}
}


How to take that total in the footer of gridview ?
Can anyone tell me where i m wrong...
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=84639
thanxss......
   

- Advertisement -