Click here to Skip to main content
14,666,385 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello friends,
I have been trying to set up a database in VB 2010.
I have a table Called: Sales, which contains following columns,
Price, Quantity, Tax and Amount.
What I wish to do is, Multiply, Price, Quantity and Tax data to Amount Column instantly as the above fields are entered.
I have created a database using MSSql.
When I try adding a query to the default TableAdapter, it gives something called as Schema error.
So, I added a new Adapter and a query,
SELECT PRICE, TAX, Quantity, PRICE*TAX*Quantity AS Amount FROM sales
It got executed correctly, but I am unable to get it working with the table.
What should i do?
Posted

Rate this:
Please Sign up or sign in to vote.

Solution 1

One way is to use CellValidated[^] event and place your calculations in there.

If you use a data table as underlying data source, you could also consider adding a computed column in the data table.
   
Comments
Sandeep Mewara 10-May-12 23:11pm
   
Yep 5!
Wendelius 11-May-12 0:55am
   
Thanks :)
Rate this:
Please Sign up or sign in to vote.

Solution 2

Please refer following threads:

This article demonstrates how to develop client side calculations in a GridView, and calculation expressions are configurable at the DB side:
Database driven client side calculations in GridView[^]

Using JavaScript/JQuery:
Calculating GridView total using JavaScript/JQuery[^]

How To Add client side calculation for gridview column[^]
Display Sum Total in the Footer of the GridView Control[^]

GridView Examples for ASP.NET: Displaying Summary Data in the Footer[^]
Displaying Summary Information in the GridView's Footer[^]

Check similar discussion on following link:
Calculate Total Value In Gridvew In ASP.net C#[^]

Hope you get some needful from it!
   
Comments
Sandeep Mewara 10-May-12 23:12pm
   
Based on tags, it looks like a winform and not ASP.NET.

Might be OP has not tagged correctly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100