.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Display total in gridview footer

Posted By: Ramesh     Posted Date: February 11, 2010    Points:2   Category :ASP.Net
Hi,

I need to display total in gridview footer or at bottom row. for each column.

Every column cell contain decimal value. I am using C# and asp.net

Regards,
Ramesh

Responses
Author: Sagar Pardeshi             
Posted Date: February 12, 2010     Points: 5   

Hi check following link
http://aspalliance.com/782

http://www.jigar.net/howdoi/viewhtmlcontent195.aspx


at last link u see live demo

Author: Syed Shakeer Hussain             
Posted Date: February 12, 2010     Points: 5   

Hi Ramesh,
You can find an article in dontspark itself.
Check the below link.
http://www.dotnetspark.com/kb/606-how-to-display-toatal-amount-salary-as-footer.aspx 


Author: Lalij Mer             
Posted Date: February 12, 2010     Points: 5   

Try this code

public partial class _Default : System.Web.UI.Page
{
decimal grdTotal = 0;
protected void Page_Load(object sender, EventArgs e)
{

}
protected void GridView1_RowDataBound
(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal rowTotal = Convert.ToDecimal
(DataBinder.Eval(e.Row.DataItem, "Amount"));
grdTotal = grdTotal + rowTotal;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl = (Label)e.Row.FindControl("lblTotal");
lbl.Text = grdTotal.ToString("c");
}
}
}

more code sample
---------------
http://aspalliance.com/782_CodeSnip_How_to_Display_Sum_Total_in_the_Footer_of_the_GridView_Control

Please Check my answer if you help....
Thank You...

Lalit.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend