Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Can Anyone give me C# coding:


in my grid view i have price and quantity ,quantity is editable textbox if i change quantity values it calculate total price as price*quantity, totalprice field is outside the grid view how can i calculate & show total price.
Posted

 
Share this answer
 
Comments
Аslam Iqbal 1-Dec-11 0:31am    
good link. 5
Abhinav S 1-Dec-11 3:00am    
Thanks.
Try the following codes:

C#
int qty = 0;
int amount = 0;
int rowTotal = 0;
int subTotal = 0;
int total = 0;
foreach(GridViewRow row in GridView1.Rows)
{
   qty = Convert.ToInt32(row.Cells[0].Text); //replace 0 with row cell index of qty
   amount = Convert.ToInt32(row.Cells[1].Text); //replace 1 with row cell index of amount
   rowTotal = qty * amount;   
   subTotal += rowTotal
}
total = subTotal;
Label1.Text = total.ToString();


Please Mark as answer and vote 5 if this solved your problem

Best regards,
Eduard
 
Share this answer
 
v2
Comments
Аslam Iqbal 1-Dec-11 0:27am    
Completed solution. my 5 :)
[no name] 1-Dec-11 0:31am    
thanks aslam!
Аslam Iqbal 1-Dec-11 0:46am    
you are welcome.

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