You cannot use TextBox control to do this. You need their texts and convert them into integer or double type for calculation.
Something like this:
Dim totalpounds As TextBox = DirectCast(gvr.FindControl("TextBox1"), TextBox)
Dim total_p As Integer = Convert.ToInt32(totalpounds.Text)
Dim changedpounds As TextBox = DirectCast(gvr.FindControl("LastAmount"), TextBox)
Dim total_c As Integer = Convert.ToInt32(changedpounds.Text)
Dim lbs As Integer = Convert.ToInt32(DirectCast(gvr.FindControl("lblLbs1"), Label).Text) '... other control
If total_p <> total_c Then
cases = total_p \ lbs
End If
If you use different data type for total and other values, just change to Convert.othertype() method to cast.
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Gridview: editing one cell and updating based on calculation
Dec 30, 2010 12:25 AM|LINK
Hi richard1970,
You cannot use TextBox control to do this. You need their texts and convert them into integer or double type for calculation.
Something like this:
Dim totalpounds As TextBox = DirectCast(gvr.FindControl("TextBox1"), TextBox)
Dim total_p As Integer = Convert.ToInt32(totalpounds.Text)
Dim changedpounds As TextBox = DirectCast(gvr.FindControl("LastAmount"), TextBox)
Dim total_c As Integer = Convert.ToInt32(changedpounds.Text)
Dim lbs As Integer = Convert.ToInt32(DirectCast(gvr.FindControl("lblLbs1"), Label).Text)
'... other control
If total_p <> total_c Then
cases = total_p \ lbs
End If
If you use different data type for total and other values, just change to Convert.othertype() method to cast.
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework