Before I would ask my nth question, I would like to thank everybody for your help. As an aspiring c# programmer your valued response is really a big help.
I'm trying to make a cashiering system. For the details I'm using a gridview with a rows that are dynamically added. Now, I want to get the sum of the column "Amount Paid" but all the codes that I tried failed. Please note that this is a data entry. To make my self clear, I'm attaching an image and my code behind. Thanks in advance for your help.
Below is my code:
- decimal amount = 0;
- protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
-
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- decimal amount = Convert.ToDecimal(e.Row.Cells[12].FindControl("txtNetAmountReceived").ToString());
- amount += Convert.ToDecimal(amount);
- }
-
-
- if (e.Row.RowType == DataControlRowType.Footer)
- {
- Label lblamount = (Label)e.Row.FindControl("lblAmountPaid");
- NetPremium.Value = totalPaid.ToString("N2");
-
- }
- }