Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
Sum of Gridview colum that has a dynamically added row.
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Hold On
7y
195
1
Reply
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"
);
}
}
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How to add javascript file link in aspx page?
Why we need OOPs in Programming language?