Answered by:
How to calculate percentages of column values with GridView

Question
-
User1263723517 posted
I'm currently working on a school project with ASP.net where a user must input a lot of data, including percentages and I would like to be able to calculate all the percentages input by the user below the gridview. I am using an SQL database to insert the data in and pull back out and display using the gridviews. All I'd like is to have the total average of all the percentages input by the user calculated and displayed at the bottom under the gridview.
I used ideone to post my code if that's fine.
Thank you.
Sunday, April 25, 2021 4:54 AM
Answers
-
User-939850651 posted
Hi EvanKnight11,
All I'd like is to have the total average of all the percentages input by the user calculated and displayed at the bottom under the gridview.According to your description, I'm not sure which column in the code you provided is what you describe.
@QuestionNum? The calculated value between the columns? Or anything other?
If you know how to get (query) the average value, then you can display the value at the bottom of the GirdView in the GridView_OnRowDataBound() event. Maybe you can choose to display it in the GridView Footer.
Here is a complete example, you could refer to it: Displaying Summary Information in the GridView's Footer (C#)
If I misunderstood anything, could you provide more details?
Best regards,
Xudong Peng
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 26, 2021 8:56 AM
All replies
-
User-1716253493 posted
SELECT AVG(Percencol) From TableName
Sunday, April 25, 2021 7:47 PM -
User-939850651 posted
Hi EvanKnight11,
All I'd like is to have the total average of all the percentages input by the user calculated and displayed at the bottom under the gridview.According to your description, I'm not sure which column in the code you provided is what you describe.
@QuestionNum? The calculated value between the columns? Or anything other?
If you know how to get (query) the average value, then you can display the value at the bottom of the GirdView in the GridView_OnRowDataBound() event. Maybe you can choose to display it in the GridView Footer.
Here is a complete example, you could refer to it: Displaying Summary Information in the GridView's Footer (C#)
If I misunderstood anything, could you provide more details?
Best regards,
Xudong Peng
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 26, 2021 8:56 AM -
User1263723517 posted
Thank you for this, I was able to get it.
Monday, April 26, 2021 6:51 PM