Sreekanth_Nagabandi
asked on
Index was out of range
Hi,
I am getting an error message at the following line. Please look at the following line in the below method and resolve the error.
AlarmView.Nodes.Item(1).Te xt = CInt(txt_max_value.Text)
Error Message :- Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Protected Sub but_update_condition_Click (ByVal sender As Object, ByVal e As System.EventArgs) Handles but_update_condition.Click
ConnectToDb()
Dim sel_node As String
Dim con_id As Integer
Dim min_value As Integer
Dim max_value As Integer
Dim signal_id As String
Dim alarm_field_condition_id As Integer
' AlarmId = 110
AlarmId = Session("AlarmId")
'Response.Write(AlarmId)
'Session("AlarmId") = AlarmId
sel_node = AlarmView.SelectedValue
If Len(sel_node) > 3 And sel_node.Substring(0, 3) = "CON" Then
con_id = sel_node.Substring(3)
Else
Exit Sub
End If
'Dim sql As String
'sql = "update v_alarm_definition_list "
min_value = CInt(txt_min_value.Text)
max_value = CInt(txt_max_value.Text)
signal_id = " & ddl_signal_name.SelectedVa lue & "
Dim include_min As String
Dim include_max As String
If ddl_include_min.SelectedVa lue = "LT" Then
include_min = "N"
Else
include_min = "Y"
End If
If ddl_include_max.SelectedVa lue = "LT" Then
include_max = "N"
Else
include_max = "Y"
End If
include_min = " & include_min & "
include_max = " & include_max & "
alarm_field_condition_id = CInt(con_id)
'sql = sql & "include_max = '" & include_max & "' "
'sql = sql & " where alarm_field_condition_id = " & con_id
Try
AlarmView.Nodes.Item(0).Te xt = CInt(txt_min_value.Text)
AlarmView.Nodes.Item(1).Te xt = CInt(txt_max_value.Text)
AlarmView.Nodes.Item(4).Te xt = ddl_signal_name.SelectedVa lue
AlarmView.DataBind()
' Dim cmd As New SqlCommand(sql, Conn)
' Dim row_count = cmd.ExecuteNonQuery
'cmd.Dispose()
Catch ex As Exception
End Try
ReloadTree()
DisconnectFromDb()
End Sub
Thanks,
Sreekanth
I am getting an error message at the following line. Please look at the following line in the below method and resolve the error.
AlarmView.Nodes.Item(1).Te
Error Message :- Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Protected Sub but_update_condition_Click
ConnectToDb()
Dim sel_node As String
Dim con_id As Integer
Dim min_value As Integer
Dim max_value As Integer
Dim signal_id As String
Dim alarm_field_condition_id As Integer
' AlarmId = 110
AlarmId = Session("AlarmId")
'Response.Write(AlarmId)
'Session("AlarmId") = AlarmId
sel_node = AlarmView.SelectedValue
If Len(sel_node) > 3 And sel_node.Substring(0, 3) = "CON" Then
con_id = sel_node.Substring(3)
Else
Exit Sub
End If
'Dim sql As String
'sql = "update v_alarm_definition_list "
min_value = CInt(txt_min_value.Text)
max_value = CInt(txt_max_value.Text)
signal_id = " & ddl_signal_name.SelectedVa
Dim include_min As String
Dim include_max As String
If ddl_include_min.SelectedVa
include_min = "N"
Else
include_min = "Y"
End If
If ddl_include_max.SelectedVa
include_max = "N"
Else
include_max = "Y"
End If
include_min = " & include_min & "
include_max = " & include_max & "
alarm_field_condition_id = CInt(con_id)
'sql = sql & "include_max = '" & include_max & "' "
'sql = sql & " where alarm_field_condition_id = " & con_id
Try
AlarmView.Nodes.Item(0).Te
AlarmView.Nodes.Item(1).Te
AlarmView.Nodes.Item(4).Te
AlarmView.DataBind()
' Dim cmd As New SqlCommand(sql, Conn)
' Dim row_count = cmd.ExecuteNonQuery
'cmd.Dispose()
Catch ex As Exception
End Try
ReloadTree()
DisconnectFromDb()
End Sub
Thanks,
Sreekanth
The error that you are getting is that there is no AlarmView.Nodes.Item(1) There is a AlarmView.Nodes.Item(0). Place a breakpoint at that line and see what if that is in AlarmView is what you think is there.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if AlarmView.Nodes > 1 then
AlarmView.Nodes.Item(1).Te
end if