In this web programming tutorial we will learn that how we can SUM the grid view columns values in asp.net using c#.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
Code for .cs file
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { grdItems.DataSource = new Item().Items; grdItems.DataBind(); } } public class Item { public string Name { get; set; } public int Quantity { get; set; } public decimal Price { get; set; } public List- Items { get { return new List
- () { new Item(){Name = "Item01",Quantity = 10,Price = 180M}, new Item(){Name = "Item01",Quantity = 11,Price = 184M}, new Item(){Name = "Item01",Quantity = 12,Price = 190M}, new Item(){Name = "Item01",Quantity = 13,Price = 110M}, }; } } }