---
title: "How to sum of value in gridview select data from database in asp.net"  
description: "How to sum of value in gridview select data from database in asp.net"  
author: "Takeshi Okada"  
published: 2013-05-09  
updated: 2013-05-09  
canonical: https://www.mindstick.com/forum/843/how-to-sum-of-value-in-gridview-select-data-from-database-in-asp-dot-net  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to sum of value in gridview select data from database in asp.net

Hi!\
I want to display PF and ESI [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) from [basic](https://www.mindstick.com/forum/161830/what-are-the-security-risks-of-using-basic-authentication) salary and total PF and ESI in [gridview](https://www.mindstick.com/articles/873/update-delete-edit-gridview-in-asp-dot-net) footer in [Indian](https://yourviews.mindstick.com/view/84678/what-if-indian-industrialist-gautam-adani-went-bankrupt) currency. \
Please help me asap.\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi Takeshi!\
You can try as following\
you have to write the code in RowDataBound Event of gridview.\
I am posting a sample code for your reference try it yourself\
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { Label lblPrice = (Label)e.Row.FindControl("lblPrice"); Label lblUnitsInStock = (Label)e.Row.FindControl("lblUnitsInStock");\
decimal price = Decimal.Parse(lblPrice.Text); decimal stock = Decimal.Parse(lblUnitsInStock.Text);\
totalPrice += price; totalStock += stock;\
totalItems += 1; }\
if (e.Row.RowType == DataControlRowType.Footer) { Label lblTotalPrice = (Label)e.Row.FindControl("lblTotalPrice"); Label lblTotalUnitsInStock = (Label)e.Row.FindControl("lblTotalUnitsInStock");\
lblTotalPrice.Text = totalPrice.ToString(); lblTotalUnitsInStock.Text = totalStock.ToString();\
lblAveragePrice.Text = (totalPrice / totalItems).ToString("F"); }}\
I hope it resolve your problem\


---

Original Source: https://www.mindstick.com/forum/843/how-to-sum-of-value-in-gridview-select-data-from-database-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
