ASP.NET - get values in thirdrd text box after multiplication

Asked By hitesh jain on 10-Jan-12 11:11 AM
sir,
   how do you multiply two text boxes and get value tn third box if value integer or not only in asp.net and click the gridview edit event when only two text box value editable not third text box and after click on update event save value in gridview after multiply of two text boxes


please help me sir

sir i am in test please give me urgently solution

thanks and regards
hitesh jain
[)ia6l0 iii replied to hitesh jain on 10-Jan-12 11:27 AM
I would rather handle these kind of computations at the stored procedure level. 
SELECT  value1, value2, (value1  * value2) AS value3 FROM tablename. 

If you have to do it on the gridview, when the user is creating a row or something: Then hook client side events that computes this for you.


Jitendra Faye replied to hitesh jain on 10-Jan-12 02:18 PM
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