Solved

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index  Description: An unhandled exception occurred during the execution

Posted on 2011-09-06
5
681 Views
Last Modified: 2012-05-12
I am receiving the following error when trying to browse *.ASPX page through IIS. The source code is coming from VB script as you will see attached VBScript.  This is be displayed from SQL in a Gridview.

Server Error in '/' Application.
--------------------------------------------------------------------------------

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Source Error:


Line 753:
Line 754:
Line 755:        If (Len(GridView20.Rows(0).Cells(0).Text) > 18) Then
Line 756:            LabelName20.Text = Left(GridView20.Rows(0).Cells(0).Text, 18)
Line 757:        Else : LabelName20.Text = GridView20.Rows(0).Cells(0).Text
 

Source File: C:\Inetpub\KPIv3\SAI-Repair-Index.aspx.vb    Line: 755

Stack Trace:


[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
   System.Collections.ArrayList.get_Item(Int32 index) +7487768
   System.Web.UI.WebControls.GridViewRowCollection.get_Item(Int32 index) +13
   SAI_Repair_Index.form1_Load(Object sender, EventArgs e) in C:\Inetpub\KPIv3\SAI-Repair-Index.aspx.vb:755
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3623; ASP.NET Version:2.0.50727.3618  Server Error in '/' Application.
Imports System.Web.UI.WebControls.Label


Partial Class SAI_Repair_Index
    Inherits System.Web.UI.Page

    Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load

        Dim nb_day As Integer
        Dim month As Integer
        month = GridView11.Rows(0).Cells(4).Text
        If (month = 1 Or month = 3 Or month = 5 Or month = 7 Or month = 8 Or month = 10 Or month = 31) Then
            nb_day = 31
        Else : nb_day = 30
        End If
        If (month = 2) Then
            nb_day = 28
        End If


        'Last Update
        LabelValueLastUpdate.Text = GridViewLastUpdate.Rows(0).Cells(0).Text
	
        If (Len(GridView1.Rows(0).Cells(0).Text) > 20) Then
            LabelName1.Text = Left(GridView1.Rows(0).Cells(0).Text, 20)
        Else : LabelName1.Text = GridView1.Rows(0).Cells(0).Text
        End If
        LabelValue1.Text = GridView1.Rows(0).Cells(1).Text
        'LabelEvolution1.Text = GridView1.Rows(0).Cells(2).Text
        If (Left(GridView1.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution1.Text = GridView1.Rows(0).Cells(2).Text
        Else : LabelEvolution1.Text = "+ " + GridView1.Rows(0).Cells(2).Text
        End If

        'If (GridView1.Rows(0).Cells(2).Text) > 0 Then
        'LabelEvolution1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        'Else : LabelEvolution1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        ' End If
        LabelTarget1.Text = GridView1.Rows(0).Cells(3).Text + " Units"
        Dim Tableau1() As String
        Dim i1 As Integer
        'Dim symbol As String
        ' symbol = "<"
        Tableau1 = Split(GridView1.Rows(0).Cells(3).Text, " ")
        i1 = GridView1.Rows(0).Cells(3).Text
        'LabelTarget1.Text = Asc(">")
        'If (StrComp(Tableau1(1), "<") = 0) Then
        'If (Asc(Tableau1(1)) = Asc("<")) Then
        If ((GridView1.Rows(0).Cells(1).Text) <= i1) Then
            LabelValue1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If
        'End If

        'If (Tableau1(1) = ">") Then
        'If (StrComp(Tableau1(1), ">") = 0) Then
        'LabelTarget1.Text = GridView1.Rows(0).Cells(3).Text
        'If (InStr(UCase(Tableau1(1)), symbol) = 0) Then
        ' If ((GridView1.Rows(0).Cells(1).Text) > i1) Then
        '  LabelTarget1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        ' Else : LabelTarget1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        'End If
        ' End If




        If (Len(GridView2.Rows(0).Cells(0).Text) > 20) Then
            LabelName2.Text = Left(GridView2.Rows(0).Cells(0).Text, 20)
        Else : LabelName2.Text = GridView2.Rows(0).Cells(0).Text
        End If
        LabelValue2.Text = GridView2.Rows(0).Cells(1).Text
        'LabelEvolution2.Text = GridView2.Rows(0).Cells(2).Text
        If (Left(GridView2.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution2.Text = GridView2.Rows(0).Cells(2).Text
        Else : LabelEvolution2.Text = "+ " + GridView2.Rows(0).Cells(2).Text
        End If

        'If (LabelEvolution2.Text) > 0 Then
        'LabelEvolution2.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        'Else : LabelEvolution2.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        ' End If
        LabelTarget2.Text = GridView2.Rows(0).Cells(3).Text + " Days"

        Dim i2 As Integer
        ' i2 = Mid(GridView2.Rows(0).Cells(3).Text, 12, 3)
        i2 = GridView2.Rows(0).Cells(3).Text
        If ((GridView2.Rows(0).Cells(1).Text) <= i2) Then
            LabelValue2.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue2.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If




        If (Len(GridView3.Rows(0).Cells(0).Text) > 24) Then
            LabelName3.Text = Left(GridView3.Rows(0).Cells(0).Text, 2)
        Else : LabelName3.Text = GridView3.Rows(0).Cells(0).Text
        End If
        'LabelValue3.Text = Right(GridView3.Rows(0).Cells(1).Text, 2) + "%"
        Dim label3_temp As Integer
        If (Len(GridView3.Rows(0).Cells(1).Text) = 3) Then
            label3_temp = Right(GridView3.Rows(0).Cells(1).Text, 1) + "0"
            LabelValue3.Text = Right(GridView3.Rows(0).Cells(1).Text, 1) + "0" + "%"
        Else
            label3_temp = Right(GridView3.Rows(0).Cells(1).Text, 2)
            LabelValue3.Text = Right(GridView3.Rows(0).Cells(1).Text, 2) + "%"
        End If

        If (Right(GridView3.Rows(0).Cells(1).Text, 2) = 1) Then
            label3_temp = Right(GridView3.Rows(0).Cells(1).Text, 1) + "00"
            LabelValue3.Text = Right(GridView3.Rows(0).Cells(1).Text, 1) + "00%"
        End If
        ' LabelEvolution3.Text = GridView3.Rows(0).Cells(2).Text + " %"

        If (Right(GridView3.Rows(0).Cells(2).Text, 2) < 10) Then
            LabelEvolution3.Text = Right(GridView3.Rows(0).Cells(2).Text, 1) + "%"
        Else : LabelEvolution3.Text = Right(GridView3.Rows(0).Cells(2).Text, 2) + "%"
        End If

        If (Len(GridView3.Rows(0).Cells(2).Text) = 3) Then
            LabelEvolution3.Text = Right(GridView3.Rows(0).Cells(2).Text, 1) + "0%"
        End If

        If (Left(GridView3.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution3.Text = "- " + LabelEvolution3.Text
        Else : LabelEvolution3.Text = "+ " + LabelEvolution3.Text
        End If

        LabelTarget3.Text = Right(GridView3.Rows(0).Cells(3).Text, 1) + "0 %"
        Dim i3 As Integer
        i3 = Right(GridView3.Rows(0).Cells(3).Text, 1) + "0"
        If (label3_temp >= i3) Then
            'If Left(GridView3.Rows(0).Cells(2).Text, 1) = "+" Then
            'LabelEvolution3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
            ' Else
            'LabelEvolution3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
            'End If
            LabelTarget3.Text = Right(GridView3.Rows(0).Cells(3).Text, 1) + "0 %"
            'Dim Tableau3() As String
            'Tableau3 = Split(GridView3.Rows(0).Cells(3).Text, " ")
            LabelValue3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If



        If (Len(GridView4.Rows(0).Cells(0).Text) > 24) Then
            LabelName4.Text = Left(GridView4.Rows(0).Cells(0).Text, 20)
        Else : LabelName4.Text = GridView4.Rows(0).Cells(0).Text
        End If
        LabelValue4.Text = GridView4.Rows(0).Cells(1).Text
        'LabelEvolution4.Text = GridView4.Rows(0).Cells(2).Text
        If (Left(GridView4.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution4.Text = GridView4.Rows(0).Cells(2).Text
        Else : LabelEvolution4.Text = "+ " + GridView4.Rows(0).Cells(2).Text
        End If

        'If (GridView4.Rows(0).Cells(2).Text) > 0 Then
        'LabelEvolution4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        ' Else : LabelEvolution4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        ' End If
        LabelTarget4.Text = GridView5.Rows(0).Cells(3).Text + " Units"
        Dim i4 As Integer
        i4 = GridView4.Rows(0).Cells(3).Text
        If ((GridView4.Rows(0).Cells(1).Text) <= i4) Then
            LabelValue4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If





        If (Len(GridView5.Rows(0).Cells(0).Text) > 24) Then
            LabelName5.Text = Left(GridView5.Rows(0).Cells(0).Text, 20)
        Else : LabelName5.Text = GridView5.Rows(0).Cells(0).Text
        End If
        LabelValue5.Text = GridView5.Rows(0).Cells(1).Text
        'LabelEvolution5.Text = GridView5.Rows(0).Cells(2).Text
        If (Left(GridView5.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution5.Text = GridView5.Rows(0).Cells(2).Text
        Else : LabelEvolution5.Text = "+ " + GridView5.Rows(0).Cells(2).Text
        End If
        'If (GridView5.Rows(0).Cells(2).Text) > 0 Then
        'LabelEvolution5.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        ' Else : LabelEvolution5.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        'End If
        LabelTarget5.Text = GridView5.Rows(0).Cells(3).Text + " Days"
        Dim i5 As Integer
        i5 = GridView5.Rows(0).Cells(3).Text
        If ((GridView5.Rows(0).Cells(1).Text) <= i5) Then
            LabelValue5.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue5.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If



        Dim label6_temp As Integer
        If (Len(GridView6.Rows(0).Cells(0).Text) > 24) Then
            LabelName6.Text = Left(GridView6.Rows(0).Cells(0).Text, 20)
        Else : LabelName6.Text = GridView6.Rows(0).Cells(0).Text
        End If
        If (Len(GridView6.Rows(0).Cells(1).Text) = 3) Then
            label6_temp = Right(GridView6.Rows(0).Cells(1).Text, 1) + "0"
            LabelValue6.Text = Right(GridView6.Rows(0).Cells(1).Text, 1) + "0" + "%"
        Else
            label6_temp = Right(GridView6.Rows(0).Cells(1).Text, 2)
            LabelValue6.Text = Right(GridView6.Rows(0).Cells(1).Text, 2) + "%"
        End If
        If (Right(GridView6.Rows(0).Cells(1).Text, 2) = 1) Then
            label6_temp = Right(GridView6.Rows(0).Cells(1).Text, 1) + "00"
            LabelValue6.Text = Right(GridView6.Rows(0).Cells(1).Text, 1) + "00%"
        End If
        'LabelEvolution6.Text = GridView6.Rows(0).Cells(2).Text + " %"


        If (Right(GridView6.Rows(0).Cells(2).Text, 2) < 10) Then
            LabelEvolution6.Text = Right(GridView6.Rows(0).Cells(2).Text, 1) + "%"
        Else : LabelEvolution6.Text = Right(GridView6.Rows(0).Cells(2).Text, 2) + "%"
        End If
        If (Len(GridView6.Rows(0).Cells(2).Text) = 3) Then
            LabelEvolution6.Text = Right(GridView6.Rows(0).Cells(2).Text, 1) + "0%"
        End If
        If (Left(GridView6.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution6.Text = "- " + LabelEvolution6.Text
        Else : LabelEvolution6.Text = "+ " + LabelEvolution6.Text
        End If

        LabelTarget6.Text = Right(GridView6.Rows(0).Cells(3).Text, 1) + "0 %"
        Dim i6 As Integer
        i6 = Right(GridView6.Rows(0).Cells(3).Text, 1) + "0"
        If (label6_temp >= i6) Then
            LabelValue6.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue6.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If





        If (Len(GridView7.Rows(0).Cells(0).Text) > 20) Then
            LabelName7.Text = Left(GridView7.Rows(0).Cells(0).Text, 20)
        Else : LabelName7.Text = GridView7.Rows(0).Cells(0).Text
        End If

        Dim i7_value As Integer
        LabelValue7.Text = GridView7.Rows(0).Cells(1).Text
        i7_value = GridView7.Rows(0).Cells(1).Text
        'LabelEvolution7.Text = GridView7.Rows(0).Cells(2).Text
        If (Left(GridView7.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution7.Text = GridView7.Rows(0).Cells(2).Text
        Else : LabelEvolution7.Text = "+ " + GridView7.Rows(0).Cells(2).Text
        End If

        'If (GridView7.Rows(0).Cells(2).Text) > 0 Then
        'LabelEvolution7.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        'Else : LabelEvolution7.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        'End If
        Dim i7 As Integer
        i7 = GridView11.Rows(0).Cells(4).Text
        LabelTarget7.Text = GridView7.Rows(0).Cells(3).Text + " Units"

        Dim i7_target As Double

        i7_target = GridView7.Rows(0).Cells(3).Text / nb_day

        'i7 = GridView7.Rows(0).Cells(3).Text
        'If ((GridView7.Rows(0).Cells(1).Text) > i7) Then
        If ((i7_target * i7) <= i7_value) Then
            LabelValue7.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue7.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If




        If (Len(GridView8.Rows(0).Cells(0).Text) > 24) Then
            LabelName8.Text = Left(GridView8.Rows(0).Cells(0).Text, 20)
        Else : LabelName8.Text = GridView8.Rows(0).Cells(0).Text
        End If

        Dim i8_value As Integer
        LabelValue8.Text = GridView8.Rows(0).Cells(1).Text
        i8_value = GridView8.Rows(0).Cells(1).Text
        'LabelEvolution8.Text = GridView8.Rows(0).Cells(2).Text
        If (Left(GridView8.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution8.Text = GridView8.Rows(0).Cells(2).Text
        Else : LabelEvolution8.Text = "+ " + GridView8.Rows(0).Cells(2).Text
        End If

        'If (GridView8.Rows(0).Cells(2).Text) > 0 Then
        'LabelEvolution8.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        ' Else : LabelEvolution8.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        ' End If
        LabelTarget8.Text = GridView8.Rows(0).Cells(3).Text + " Units"

        Dim i8_target As Double
        i8_target = GridView8.Rows(0).Cells(3).Text / nb_day
        Dim i8 As Integer
        'i8 = GridView8.Rows(0).Cells(3).Text
        i8 = GridView11.Rows(0).Cells(4).Text
        'If ((GridView8.Rows(0).Cells(1).Text) < i8) Then
        If ((i8_target * i8) >= i8_value) Then
            LabelValue8.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue8.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If





        If (Len(GridView9.Rows(0).Cells(0).Text) > 24) Then
            LabelName9.Text = Left(GridView9.Rows(0).Cells(0).Text, 20)
        Else : LabelName9.Text = GridView9.Rows(0).Cells(0).Text
        End If
        Dim i9_value As Integer
        LabelValue9.Text = GridView9.Rows(0).Cells(1).Text
        i9_value = LabelValue9.Text
        'LabelEvolution9.Text = GridView9.Rows(0).Cells(2).Text
        If (Left(GridView9.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution9.Text = GridView9.Rows(0).Cells(2).Text
        Else : LabelEvolution9.Text = "+ " + GridView9.Rows(0).Cells(2).Text
        End If

        'If (GridView9.Rows(0).Cells(2).Text) > 0 Then
        'LabelEvolution9.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        'Else : LabelEvolution9.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        'End If
        LabelTarget9.Text = GridView9.Rows(0).Cells(3).Text + " Units"
        Dim i9 As Integer
        Dim i9_target As Double
        ' i9 = GridView9.Rows(0).Cells(3).Text
        i9_target = GridView9.Rows(0).Cells(3).Text / nb_day
        i9 = GridView11.Rows(0).Cells(4).Text
        'If ((GridView9.Rows(0).Cells(1).Text) > i9) Then
        If ((i9_target * i9) <= i9_value) Then
            LabelValue9.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue9.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If





        '% Workable
        If (Len(GridView10.Rows(0).Cells(0).Text) > 20) Then
            LabelName10.Text = Left(GridView10.Rows(0).Cells(0).Text, 20)
        Else : LabelName10.Text = GridView10.Rows(0).Cells(0).Text
        End If
        Dim label10_temp As Integer
        'LabelValue11.Text = Right(GridView11.Rows(0).Cells(1).Text, 1) + "%"
        If (Right(GridView10.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue10.Text = Right(GridView10.Rows(0).Cells(1).Text, 1) + "%"
            label10_temp = Right(GridView10.Rows(0).Cells(1).Text, 1)
        Else : LabelValue10.Text = Right(GridView10.Rows(0).Cells(1).Text, 2) + "%"
            label10_temp = Right(GridView10.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView10.Rows(0).Cells(1).Text) = 3) Then
            LabelValue10.Text = Right(GridView10.Rows(0).Cells(1).Text, 1) + "0%"
            label10_temp = Right(GridView10.Rows(0).Cells(1).Text, 1) + "0"
        End If
        If (Right(GridView10.Rows(0).Cells(1).Text, 2) = 1) Then
            label10_temp = Right(GridView10.Rows(0).Cells(1).Text, 1) + "00"
            LabelValue10.Text = Right(GridView10.Rows(0).Cells(1).Text, 1) + "00%"
        End If


        If (Right(GridView10.Rows(0).Cells(2).Text, 2) < 10) Then
            LabelEvolution10.Text = Right(GridView10.Rows(0).Cells(2).Text, 1) + "%"
        Else : LabelEvolution10.Text = Right(GridView10.Rows(0).Cells(2).Text, 2) + "%"
        End If

        If (Left(GridView10.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution10.Text = "- " + LabelEvolution10.Text
        Else : LabelEvolution10.Text = "+ " + LabelEvolution10.Text
        End If

        If (Len(GridView10.Rows(0).Cells(2).Text) = 3) Then
            LabelEvolution10.Text = Right(GridView10.Rows(0).Cells(2).Text, 1) + "0%"
        End If
        'LabelEvolution10.Text = GridView10.Rows(0).Cells(2).Text + " %"
        LabelTarget10.Text = Right(GridView10.Rows(0).Cells(3).Text, 1) + "0 %"
        'LabelEvolution10.Text = GridView10.Rows(0).Cells(2).Text
        'If Left(GridView10.Rows(0).Cells(2).Text, 1) = "+" Then
        'LabelEvolution10.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        'Else
        'LabelEvolution10.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        'End If
        Dim i10 As Integer
        i10 = Right(GridView10.Rows(0).Cells(3).Text, 1) + "0"
        If (label10_temp >= i10) Then
            LabelValue10.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue10.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If





        If (Len(GridView11.Rows(0).Cells(0).Text) > 20) Then
            LabelName11.Text = Left(GridView11.Rows(0).Cells(0).Text, 20)
        Else : LabelName11.Text = GridView11.Rows(0).Cells(0).Text
        End If

        Dim label11_temp As Integer
        'LabelValue11.Text = Right(GridView11.Rows(0).Cells(1).Text, 1) + "%"
        If (Right(GridView11.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue11.Text = Right(GridView11.Rows(0).Cells(1).Text, 1) + "%"
            label11_temp = Right(GridView11.Rows(0).Cells(1).Text, 1)
        Else : LabelValue11.Text = Right(GridView11.Rows(0).Cells(1).Text, 2) + "%"
            label11_temp = Right(GridView11.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView11.Rows(0).Cells(1).Text) = 3) Then
            LabelValue11.Text = Right(GridView11.Rows(0).Cells(1).Text, 1) + "0%"
            label11_temp = Right(GridView11.Rows(0).Cells(1).Text, 1) + "0"
        End If
        If (Right(GridView11.Rows(0).Cells(1).Text, 2) = 1) Then
            label11_temp = Right(GridView11.Rows(0).Cells(1).Text, 1) + "00"
            LabelValue11.Text = Right(GridView11.Rows(0).Cells(1).Text, 1) + "00%"
        End If


        'If (Len(GridView11.Rows(0).Cells(1).Text) = 3) Then
        'label11_temp = Right(GridView11.Rows(0).Cells(1).Text, 1)
        'LabelValue11.Text = Right(GridView11.Rows(0).Cells(1).Text, 1) + "%"
        'Else
        'label11_temp = Right(GridView11.Rows(0).Cells(1).Text, 2)
        ' LabelValue11.Text = Right(GridView11.Rows(0).Cells(1).Text, 2) + "%"
        'End If

        If (Right(GridView11.Rows(0).Cells(2).Text, 2) < 10) Then
            LabelEvolution11.Text = Right(GridView11.Rows(0).Cells(2).Text, 1) + "%"
        Else : LabelEvolution11.Text = Right(GridView11.Rows(0).Cells(2).Text, 2) + "%"
        End If

        If (Len(GridView11.Rows(0).Cells(2).Text) = 3) Then
            LabelEvolution11.Text = Right(GridView11.Rows(0).Cells(2).Text, 1) + "0%"
        End If

        If (Left(GridView11.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution11.Text = "- " + LabelEvolution11.Text
        Else : LabelEvolution11.Text = "+ " + LabelEvolution11.Text
        End If

        'label11_temp = LabelEvolution11.Text

        'LabelEvolution11.Text = GridView11.Rows(0).Cells(2).Text + " %"

        'LabelTarget11.Text = Right(GridView11.Rows(0).Cells(3).Text, 1) + " %"

        'If Left(GridView10.Rows(0).Cells(2).Text, 1) = "+" Then
        'LabelEvolution10.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        'Else
        'LabelEvolution10.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        'End If
        Dim i11 As Integer
        If (Right(GridView11.Rows(0).Cells(3).Text, 2) < 10) Then
            LabelTarget11.Text = Right(GridView11.Rows(0).Cells(3).Text, 1) + " %"
            i11 = Right(GridView11.Rows(0).Cells(3).Text, 1)
        Else : LabelTarget11.Text = Right(GridView11.Rows(0).Cells(3).Text, 2) + " %"
            i11 = Right(GridView11.Rows(0).Cells(3).Text, 2)
        End If

        If (Len(GridView11.Rows(0).Cells(3).Text) = 3) Then
            LabelTarget11.Text = Right(GridView11.Rows(0).Cells(3).Text, 1) + "0%"
            i11 = Right(GridView11.Rows(0).Cells(3).Text, 1) + "0"
        End If

        If (label11_temp <= i11) Then
            LabelValue11.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue11.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If




        If (Len(GridView12.Rows(0).Cells(0).Text) > 20) Then
            LabelName12.Text = Left(GridView12.Rows(0).Cells(0).Text, 20)
        Else : LabelName12.Text = GridView12.Rows(0).Cells(0).Text
        End If
        Dim label12_temp As Integer
        If (Len(GridView12.Rows(0).Cells(1).Text) = 3) Then
            label12_temp = Right(GridView12.Rows(0).Cells(1).Text, 1) + "0"
            LabelValue12.Text = Right(GridView12.Rows(0).Cells(1).Text, 1) + "0" + "%"
        Else
            label12_temp = Right(GridView12.Rows(0).Cells(1).Text, 2)
            LabelValue12.Text = Right(GridView12.Rows(0).Cells(1).Text, 2) + "%"
        End If
        If (Right(GridView12.Rows(0).Cells(1).Text, 2) = 1) Then
            label12_temp = Right(GridView12.Rows(0).Cells(1).Text, 1) + "00"
            LabelValue12.Text = Right(GridView12.Rows(0).Cells(1).Text, 1) + "00%"
        End If

        If (Right(GridView12.Rows(0).Cells(2).Text, 2) < 10) Then
            LabelEvolution12.Text = Right(GridView12.Rows(0).Cells(2).Text, 1) + "%"
        Else : LabelEvolution12.Text = Right(GridView12.Rows(0).Cells(2).Text, 2) + "%"
        End If

        If (Len(GridView12.Rows(0).Cells(2).Text) = 3) Then
            LabelEvolution12.Text = Right(GridView12.Rows(0).Cells(2).Text, 1) + "0%"
        End If

        If (Left(GridView12.Rows(0).Cells(2).Text, 1) = "-") Then
            LabelEvolution12.Text = "- " + LabelEvolution12.Text
        Else : LabelEvolution12.Text = "+ " + LabelEvolution12.Text
        End If
        'LabelEvolution12.Text = GridView12.Rows(0).Cells(2).Text + " %"
        Labeltarget12.Text = Right(GridView12.Rows(0).Cells(3).Text, 1) + "0 %"
        'LabelEvolution12.Text = GridView12.Rows(0).Cells(2).Text
        'If Left(GridView10.Rows(0).Cells(2).Text, 1) = "+" Then
        'LabelEvolution10.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        'Else
        'LabelEvolution10.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000")
        'End If
        Dim i12 As Integer
        i12 = Right(GridView12.Rows(0).Cells(3).Text, 1) + "0"
        If (label12_temp >= i12) Then
            LabelValue12.ForeColor = System.Drawing.ColorTranslator.FromHtml("#00ff00")
        Else : LabelValue12.ForeColor = System.Drawing.ColorTranslator.FromHtml("#ff0000") 'ROUGE
        End If





        If (Len(GridView13.Rows(0).Cells(0).Text) > 18) Then
            LabelName13.Text = Left(GridView13.Rows(0).Cells(0).Text, 18)
        Else : LabelName13.Text = GridView13.Rows(0).Cells(0).Text
        End If

        'LabelValue13.Text = GridView13.Rows(0).Cells(1).Text
        If (Right(GridView13.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue13.Text = Right(GridView13.Rows(0).Cells(1).Text, 1)
        Else : LabelValue13.Text = Right(GridView13.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView13.Rows(0).Cells(1).Text) = 3) Then
            LabelValue13.Text = Right(GridView13.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView13.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue13.Text = Right(GridView13.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue13.Text <= 70 Then
            Image13.ImageUrl = "sad.jpg"
        Else
            If LabelValue13.Text >= 80 Then
                Image13.ImageUrl = "smile.jpg"
            Else
                Image13.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging13.Text = GridView13.Rows(0).Cells(3).Text




        If (Len(GridView14.Rows(0).Cells(0).Text) > 18) Then
            LabelName14.Text = Left(GridView14.Rows(0).Cells(0).Text, 18)
        Else : LabelName14.Text = GridView14.Rows(0).Cells(0).Text
        End If

        If (Right(GridView14.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue14.Text = Right(GridView14.Rows(0).Cells(1).Text, 1)
        Else : LabelValue14.Text = Right(GridView14.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView14.Rows(0).Cells(1).Text) = 3) Then
            LabelValue14.Text = Right(GridView14.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView14.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue14.Text = Right(GridView14.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue14.Text <= 70 Then
            Image14.ImageUrl = "sad.jpg"
        Else
            If LabelValue14.Text >= 80 Then
                Image14.ImageUrl = "smile.jpg"
            Else
                Image14.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging14.Text = GridView14.Rows(0).Cells(3).Text



        If (Len(GridView15.Rows(0).Cells(0).Text) > 18) Then
            LabelName15.Text = Left(GridView15.Rows(0).Cells(0).Text, 18)
        Else : LabelName15.Text = GridView15.Rows(0).Cells(0).Text
        End If

        If (Right(GridView15.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue15.Text = Right(GridView15.Rows(0).Cells(1).Text, 1)
        Else : LabelValue15.Text = Right(GridView15.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView15.Rows(0).Cells(1).Text) = 3) Then
            LabelValue15.Text = Right(GridView15.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView15.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue15.Text = Right(GridView15.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue15.Text <= 70 Then
            Image15.ImageUrl = "sad.jpg"
        Else
            If LabelValue15.Text >= 80 Then
                Image15.ImageUrl = "smile.jpg"
            Else
                Image15.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging15.Text = GridView15.Rows(0).Cells(3).Text



        If (Len(GridView16.Rows(0).Cells(0).Text) > 18) Then
            LabelName16.Text = Left(GridView16.Rows(0).Cells(0).Text, 18)
        Else : LabelName16.Text = GridView16.Rows(0).Cells(0).Text
        End If

        If (Right(GridView16.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue16.Text = Right(GridView16.Rows(0).Cells(1).Text, 1)
        Else : LabelValue16.Text = Right(GridView16.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView16.Rows(0).Cells(1).Text) = 3) Then
            LabelValue16.Text = Right(GridView16.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView16.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue16.Text = Right(GridView16.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue16.Text <= 70 Then
            Image16.ImageUrl = "sad.jpg"
        Else
            If LabelValue16.Text >= 80 Then
                Image16.ImageUrl = "smile.jpg"
            Else
                Image16.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging16.Text = GridView16.Rows(0).Cells(3).Text



        If (Len(GridView17.Rows(0).Cells(0).Text) > 18) Then
            LabelName17.Text = Left(GridView17.Rows(0).Cells(0).Text, 18)
        Else : LabelName17.Text = GridView17.Rows(0).Cells(0).Text
        End If

        If (Right(GridView17.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue17.Text = Right(GridView17.Rows(0).Cells(1).Text, 1)
        Else : LabelValue17.Text = Right(GridView17.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView17.Rows(0).Cells(1).Text) = 3) Then
            LabelValue17.Text = Right(GridView17.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView17.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue17.Text = Right(GridView17.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue17.Text <= 70 Then
            Image17.ImageUrl = "sad.jpg"
        Else
            If LabelValue17.Text >= 80 Then
                Image17.ImageUrl = "smile.jpg"
            Else
                Image17.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging17.Text = GridView17.Rows(0).Cells(3).Text



        If (Len(GridView18.Rows(0).Cells(0).Text) > 18) Then
            LabelName18.Text = Left(GridView18.Rows(0).Cells(0).Text, 18)
        Else : LabelName18.Text = GridView18.Rows(0).Cells(0).Text
        End If

        If (Right(GridView18.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue18.Text = Right(GridView18.Rows(0).Cells(1).Text, 1)
        Else : LabelValue18.Text = Right(GridView18.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView18.Rows(0).Cells(1).Text) = 3) Then
            LabelValue18.Text = Right(GridView18.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView18.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue18.Text = Right(GridView18.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue18.Text <= 70 Then
            Image18.ImageUrl = "sad.jpg"
        Else
            If LabelValue18.Text >= 80 Then
                Image18.ImageUrl = "smile.jpg"
            Else
                Image18.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging18.Text = GridView18.Rows(0).Cells(3).Text



        If (Len(GridView19.Rows(0).Cells(0).Text) > 18) Then
            LabelName19.Text = Left(GridView19.Rows(0).Cells(0).Text, 18)
        Else : LabelName19.Text = GridView19.Rows(0).Cells(0).Text
        End If

        If (Right(GridView19.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue19.Text = Right(GridView19.Rows(0).Cells(1).Text, 1)
        Else : LabelValue19.Text = Right(GridView19.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView19.Rows(0).Cells(1).Text) = 3) Then
            LabelValue19.Text = Right(GridView19.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView19.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue19.Text = Right(GridView19.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue19.Text <= 70 Then
            Image19.ImageUrl = "sad.jpg"
        Else
            If LabelValue19.Text >= 80 Then
                Image19.ImageUrl = "smile.jpg"
            Else
                Image19.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging19.Text = GridView19.Rows(0).Cells(3).Text



        If (Len(GridView20.Rows(0).Cells(0).Text) > 18) Then
            LabelName20.Text = Left(GridView20.Rows(0).Cells(0).Text, 18)
        Else : LabelName20.Text = GridView20.Rows(0).Cells(0).Text
        End If

        If (Right(GridView20.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue20.Text = Right(GridView20.Rows(0).Cells(1).Text, 1)
        Else : LabelValue20.Text = Right(GridView20.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView20.Rows(0).Cells(1).Text) = 3) Then
            LabelValue20.Text = Right(GridView20.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView20.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue20.Text = Right(GridView20.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue20.Text <= 70 Then
            Image20.ImageUrl = "sad.jpg"
        Else
            If LabelValue20.Text >= 80 Then
                Image20.ImageUrl = "smile.jpg"
            Else
                Image20.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging20.Text = GridView20.Rows(0).Cells(3).Text



        If (Len(GridView21.Rows(0).Cells(0).Text) > 18) Then
            LabelName21.Text = Left(GridView21.Rows(0).Cells(0).Text, 18)
        Else : LabelName21.Text = GridView21.Rows(0).Cells(0).Text
        End If

        If (Right(GridView21.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue21.Text = Right(GridView21.Rows(0).Cells(1).Text, 1)
        Else : LabelValue21.Text = Right(GridView21.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView21.Rows(0).Cells(1).Text) = 3) Then
            LabelValue21.Text = Right(GridView21.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView21.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue21.Text = Right(GridView21.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue21.Text <= 70 Then
            Image21.ImageUrl = "sad.jpg"
        Else
            If LabelValue21.Text >= 80 Then
                Image21.ImageUrl = "smile.jpg"
            Else
                Image21.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging21.Text = GridView21.Rows(0).Cells(3).Text



        If (Len(GridView22.Rows(0).Cells(0).Text) > 18) Then
            LabelName22.Text = Left(GridView22.Rows(0).Cells(0).Text, 18)
        Else : LabelName22.Text = GridView22.Rows(0).Cells(0).Text
        End If

        If (Right(GridView22.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue22.Text = Right(GridView22.Rows(0).Cells(1).Text, 1)
        Else : LabelValue22.Text = Right(GridView22.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView22.Rows(0).Cells(1).Text) = 3) Then
            LabelValue22.Text = Right(GridView22.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView22.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue22.Text = Right(GridView22.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue22.Text <= 70 Then
            Image22.ImageUrl = "sad.jpg"
        Else
            If LabelValue22.Text >= 80 Then
                Image22.ImageUrl = "smile.jpg"
            Else
                Image22.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging22.Text = GridView22.Rows(0).Cells(3).Text



        If (Len(GridView23.Rows(0).Cells(0).Text) > 17) Then
            LabelName23.Text = Left(GridView23.Rows(0).Cells(0).Text, 17)
        Else : LabelName23.Text = GridView23.Rows(0).Cells(0).Text
        End If

        If (Right(GridView23.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue23.Text = Right(GridView23.Rows(0).Cells(1).Text, 1)
        Else : LabelValue23.Text = Right(GridView23.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView23.Rows(0).Cells(1).Text) = 3) Then
            LabelValue23.Text = Right(GridView23.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView23.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue23.Text = Right(GridView23.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue23.Text <= 70 Then
            Image23.ImageUrl = "sad.jpg"
        Else
            If LabelValue23.Text >= 80 Then
                Image23.ImageUrl = "smile.jpg"
            Else
                Image23.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging23.Text = GridView23.Rows(0).Cells(3).Text



        If (Len(GridView24.Rows(0).Cells(0).Text) > 18) Then
            LabelName24.Text = Left(GridView24.Rows(0).Cells(0).Text, 18)
        Else : LabelName24.Text = GridView24.Rows(0).Cells(0).Text
        End If

        If (Right(GridView24.Rows(0).Cells(1).Text, 2) < 10) Then
            LabelValue24.Text = Right(GridView24.Rows(0).Cells(1).Text, 1)
        Else : LabelValue24.Text = Right(GridView24.Rows(0).Cells(1).Text, 2)
        End If

        If (Len(GridView24.Rows(0).Cells(1).Text) = 3) Then
            LabelValue24.Text = Right(GridView24.Rows(0).Cells(1).Text, 1) + "0"
        End If

        If (Right(GridView24.Rows(0).Cells(1).Text, 2) = 1) Then
            LabelValue24.Text = Right(GridView24.Rows(0).Cells(1).Text, 1) + "00"
        End If

        If LabelValue24.Text <= 70 Then
            Image24.ImageUrl = "sad.jpg"
        Else
            If LabelValue24.Text >= 80 Then
                Image24.ImageUrl = "smile.jpg"
            Else
                Image24.ImageUrl = "neutral.jpg"
            End If
        End If

        LabelTargetAging24.Text = GridView24.Rows(0).Cells(3).Text

    End Sub
End Class

Open in new window

0
Comment
Question by:jmto
5 Comments
 
LVL 4

Expert Comment

by:yesthatbob
Comment Utility
Are you sure that the GridView has data to show? If there are no rows, referencing GridView.Row(0) would throw this exception.
0
 
LVL 9

Expert Comment

by:Grant Spiteri
Comment Utility
I am in agreeance with "yesthatbob" you need to apply more defensive coding to your code ie:
before accessing properties on objects you should be checking objects are null, this inturn will avoid issues like you have received, if they are null you should probably log them and then deliver a more user friendly msg to user.
0
 
LVL 10

Accepted Solution

by:
himanshut earned 500 total points
Comment Utility
Can you put a line of code and see what number you get by :
int _count = GridView20.Rows.Count;

It will give you the exact number of how many rows are there.
Let me know if you get any count, I'm hoping it would be 0 in this case.
0
 
LVL 9

Expert Comment

by:Grant Spiteri
Comment Utility
Rows could also be null though
0
 

Author Comment

by:jmto
Comment Utility
Thanks, everyone for your input. I removed the faulty code from VBS and everything is working as it should now.

How can I cross reference on Gridview that rows are NULL against SQL?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now