Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
I have a combobox which have three different types of item. when I click on the add button then first item add in gridview then second and so on.. Now I want to sum of different types column and show output in three different textboxes.

like

scooter motorcycle cycle
10 22 11
22 33 22


I am using this code but not shows distinct value.

C#
TotalGrossGd = Convert.ToDouble(objDT.Compute("SUM(txtWeight)", ""));
TotalGrossSl = Convert.ToDouble(objDT.Compute("SUM(txtWeight)", ""));
TotalGrossAmount = Convert.ToDouble(objDT.Compute("SUM(txtTotalL)", ""));

txtGrossGd.Text = TotalGrossGd.ToString();
txtGrossSl.Text = TotalGrossSl.ToString();
txtTotalAmount.Text = TotalGrossAmount.ToString();
Posted
Comments
Marla Sukesh 11-Nov-13 22:18pm    
Its difficut to understand exactly what you are doing and what you want
indiancodinglove 11-Nov-13 23:38pm    
I have a datagridview and some textboxes. when I am click on the add button then all values show in datagridview now I want to sum of scooter in a textbox and motorcycle sum of in other textbox and total amount of purchase in other textbox which is only view at that time when the program running if I am deleting sum row in gridview then sum of scooter,motorcycle,amount will be delete at the running time

The ideal scenario would be to do this in the query and display it in the grid.
 
Share this answer
 
if you want to sum a particular record and setting datasource then you can use the "compute" function of datatable or if not setting through data source "loop" through the datagridview and add the value in a variable.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900