Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have gridview in which there 4 cloumns like dropdownlist which shows products, Rate Column, Quantity Column and Total Amount Column i want that when i enter rate and quantity total amount show automatically count.
kindly guide me

while i also tried code in gridview rowdatabound but it shows string was not in correct format

What I have tried:

C#
for (int i = 0; i < GridView1.Rows.Count; i++)
            {

               
               GridView1.Rows[i].Cells[3].Text = Convert.ToString(Convert.ToInt32(GridView1.Rows[i].Cells[1].Text.Replace('-', ',')) * Convert.ToDouble(GridView1.Rows[i].Cells[2].Text.Replace('-', ',')));

            }
Posted
Updated 1-Jun-16 2:00am
v2
Comments
Herman<T>.Instance 1-Jun-16 7:50am    
May the force be with you unless Google is banned in your country.
Karthik_Mahalingam 1-Jun-16 7:53am    
post the gridview markup code..
Maciej Los 1-Jun-16 8:06am    
What kind of GridView? WinForm, WebForm, WPF? Type full name, please.

1 solution

Use client-side script such as JavaScript so that there is no need to have a round trip to the server. Check this example using a JavaScript library of jQuery:
Calculate Row Total and Grand Total in ASP.Net GridView using jQuery[^]
 
Share this answer
 
v2

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