I am using the code below to calculate grid column values using javascript.
It is working fine, but the problem is it wasn't calculating the last column of the grid.
I'd appreciate it if anyone couuld help me in this issue.
My code:
Private Sub GD_Prod_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles GD_Prod.ItemCreated
If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = DirectCast(e.Item(), GridDataItem)
For Each item In GD_Prod.Items
Dim txtbox1 As TextBox = DirectCast(item.FindControl("TxtSTUPort"), TextBox)
Dim txtbox2 As TextBox = DirectCast(item.FindControl("TxtAAPort"), TextBox)
Dim txtbox3 As TextBox = DirectCast(item.FindControl("STD_NUM_OF_SERVING"), TextBox)
txtbox1.Attributes.Add("onblur", "show('" & txtbox1.ClientID & "','" & txtbox2.ClientID & "','" & txtbox3.ClientID & "');")
txtbox2.Attributes.Add("onblur", "show('" & txtbox1.ClientID & "','" & txtbox2.ClientID & "','" & txtbox3.ClientID & "');")
txtbox3.Attributes.Add("readonly", "readonly")
Next
End If
End Sub
Javascript code:
function show(TxtSTUPort, TxtAAPort, STD_NUM_OF_SERVING) {
var TxtSTUPort = document.getElementById(TxtSTUPort);
var TxtAAPort = document.getElementById(TxtAAPort);
var STD_NUM_OF_SERVING = document.getElementById(STD_NUM_OF_SERVING);
STD_NUM_OF_SERVING.value = parseInt(TxtSTUPort.value) + parseInt(TxtAAPort.value);
if (!parseInt(STD_NUM_OF_SERVING.value)) {
STD_NUM_OF_SERVING.value = '0';
}
UPDATE:
Solved by OP himself. Posted as an answer.