Use this code-
Private Sub GridView1_RowDataBound(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _ Handles GridView1.RowDataBound
Dim TotalCost, Quantity, Amt As Decimal
If e.Row.RowType = DataControlRowType.DataRow Then Try Quantity = Convert.ToDecimal(DirectCast(e.Row.FindControl("txtQuantity"), TextBox).Text) ' Quantity = Convert.ToDecimal(e.Row.Cells(3).Text) ' If a bound field Catch Quantity = 0 End Try
Try Amt = Convert.ToDecimal(DirectCast(e.Row.FindControl("txtAmount"), TextBox).Text) 'Amt = Convert.ToDecimal(e.Row.Cells(2).Text) ' If a bound field Catch Amt = 0 End Try TotalCost = Quantity * Amt DirectCast(e.Row.FindControl("txtEstimatedTotal"), TextBox).Text = TotalCost.ToString("$###,###.00") End If
End Sub