There are 2 variables with same name
price
, so rename any one
protected string TP()
{
float totalprice = 0;
foreach (GridViewRow rowitem in GridView1.Rows)
{
Label price1 = (Label)(rowitem.Cells[4].FindControl("price"));
TextBox txtquantity = rowitem.Cells[3].FindControl("quantity");
float price = float.Parse(price1.Text);
int quantity = int.Parse(txtquantity.Text);
totalprice = price * quantity;
}
lbltprice.Text = totalprice.ToString();
}