This one is really very useful whenever we have a need to calculate running totals in the grid either row wise or in column wise.
As per one of our DNF friend’s need I thought of writing this article. This one is really very useful whenever we have a need to calculate running totals in the grid either row wise or in column wise.
So let’s start to build this application.
Step1- Open Visual studio and add new website project.
Step2 – Rightclick on the project -> add new item -> Select xml file -> Name it as Data.xml
Step3- Create a sample data for the grid view. I have created my sample in an xml file. You can also have this in the SQL Server also.
The xml file has data for three employee salary and bonus details and we will calculate the gross salary and the total gross salary dynamically.
Step4- Add a new Gridview to the aspx page and add three bound fields and three template fields. And design as shown below
The Gross salary and the total gross salary we will calculate at runtime dynamically.
Step-5 The ASPX source will have the gridview content as below
Step-6 Load the data from xml to grid view on page load
Thats it... Build and run your application. You do any change to the salary field or bonus field the gross salary and the total gross salary gets calculated dynamically.
Hope this artical will help all to understand the how easily we can have all our calculations done with in the grid view so easily with very less code.