Jes Sie

Jes Sie

  • 741
  • 1.2k
  • 281.9k

RunningBalance in Columns of Gridview in ASP.NET Webforms C#

Oct 19 2016 4:45 AM
Hi! I created a Cash Book webform application in C#. In the columns Debit, Credit and Balance, I want to get the running balance from Debit and Credit columns. 
 I'm using a TemplateField. Here's what I started but still no luck. Hope someone can help me.
 
  1. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)  
  2.        {  
  3.   
  4.            DataRowView dtview = e.Row.DataItem as DataRowView;  
  5.            if (e.Row.RowType == DataControlRowType.DataRow)  
  6.            {  
  7.                Label Debit = (Label)e.Row.FindControl("lblDebit");  
  8.                GetDebit += GetDebit + Convert.ToDecimal(Debit.Text);  
  9.   
  10.                Label Credit = (Label)e.Row.FindControl("lblCredit");  
  11.                GetCredit += GetCredit + Convert.ToDecimal(Credit.Text);  
  12.   
  13.                Label Balance = (Label)e.Row.FindControl("lblBalanceForwared");  
  14.                GetBalance += GetBalance + Convert.ToDecimal(Balance.Text) + GetBalance- GetCredit;  
  15.   
  16.                 
  17.            }  
  18.   
  19.        }  
Another thing, I am just a neophyte in programming. Thanks in advance. 

Answers (2)