Index out of range error.

sha_shivani

Member
Joined
Sep 28, 2006
Messages
11
Programming Experience
1-3
Can someone please tell me how i can fix this error?

Top level exception
Message: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Extra information:
Type: System.ArgumentOutOfRangeException
Stack trace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at ProcessManagement.Integration.ProcessService.UpdateLoanInfo(ILoanInfo Loan)
at FileInfo.UpdateLoan(ILoanInfo& loan) in C:\FISDesktop\FISDesktop_WebApp_VB\FileScreen.aspx.vb:line 273
at FileInfo.btnSave_Click(Object sender, EventArgs e) in C:\FISDesktop\FISDesktop_WebApp_VB\FileScreen.aspx.vb:line 431
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

VB.NET:
     Private Sub LoadInvestor()
        Dim Investor As ILookupItemCollection
        Investor = New SharedLookupItemCollection(ProcMan.Svc.ListLoanInfoInvestorsByFileId(thisFile.FileID))
        If Not IsNothing(Investor) AndAlso Investor.Count() > 0 Then
            Investor.BindListControl(ddlInvestor, New ListItem("-- Select Investor--", "0"), "0")
        End If
    End Sub



    Private Sub LoadFileEditScreen()
        Dim iFile As Business.Model.Shared.Process.ILoanInfo
        iFile = ProcMan.Svc.GetLoanInfo(thisFile.FileID)

        With iFile
            'Loan Information
            If Not ddlLoanClassification.Items.FindByValue(.LoanClassification.ToString) Is Nothing Then
                Me.ddlLoanClassification.SelectedValue = .LoanClassification.ToString
            Else
                Me.ddlLoanClassification.SelectedIndex = 0
            End If
            Me.txtLoanType.Text = .LoanType
            If Not ddlLoanPosition.Items.FindByValue(.LoanPosition.ToString) Is Nothing Then
                Me.ddlLoanPosition.SelectedValue = .LoanPosition.ToString
            Else
                Me.ddlLoanPosition.SelectedIndex = 0
            End If
            Me.txtLoanOrigination.Text = .LoanOrigination
            Me.txtFirstPayment.Text = .FirstPayment
            Me.txtNextPayment.Text = .NextPayment
            Me.txtOriginalLoanAmount.Text = .OriginalLoanAmount
            Me.txtOriginalInterestRate.Text = .OriginalInterestRate
            Me.txtCurrentLoanAmount.Text = .CurrentLoanAmount
            Me.txtCurrentInterestRate.Text = .CurrentInterestRate
            Me.txtNetAmountDue.Text = .NetAmountDue
            Me.txtLoanTerm.Text = .LoanTerm
            Me.txtEscrowBalance.Text = .EscrowBalance
            Me.txtPIPayment.Text = .PIPayment
            If Not ddlPaymentFrequency.Items.FindByValue(.PaymentFrequency.ToString) Is Nothing Then
                Me.ddlPaymentFrequency.SelectedValue = .PaymentFrequency.ToString
            Else
                Me.ddlPaymentFrequency.SelectedIndex = 0
            End If
        
            If Not ddlInterestCalculationMethod.Items.FindByValue(.InterestCalculationMethod.ToString) Is Nothing Then
                Me.ddlInterestCalculationMethod.SelectedValue = .InterestCalculationMethod.ToString
            Else
                Me.ddlInterestCalculationMethod.SelectedIndex = 0
            End If
            Me.txtSuspenseBalance.Text = .SuspenseBalance
            If Not ddlOccupancyStatus.Items.FindByValue(.OccupancyStatus.ToString) Is Nothing Then
                Me.ddlOccupancyStatus.SelectedValue = .OccupancyStatus.ToString
            Else
                Me.ddlOccupancyStatus.SelectedIndex = 0
            End If
            Me.txtPostPetitionDueDate.Text = .PostPetitionDueDate

            'Investor Information
            If Not ddlInvestor.Items.FindByValue(.Investor.ToString) Is Nothing Then
                Me.ddlInvestor.SelectedValue = .Investor.ToString
            Else
                Me.ddlInvestor.SelectedIndex = 0
            End If
            Me.txtInvestorLoanNumber.Text = .InvestorLoanNumber
            Me.txtClientInvestorCode.Text = .ClientInvestorCode
            Me.txtInvestorCategory.Text = .InvestorCategory
            Me.txtInvestorName.Text = .InvestorName
            Me.txtPendingInvestorLoanNumber.Text = .PendingInvestorLoanNumber
            Me.txtPowerofAttorney.Text = .PowerOfAttorney
            Me.txtPendingInvestorChangeEffectiveDate.Text = .PendingInvestorChangeEffectiveDate
            Me.txtPendingInvestorNumber.Text = .PendingInvestorNumber
            Me.txtPendingInvestorCategory.Text = .PendingInvestorCategory
            Me.txtPendingInvestorName.Text = .PendingInvestorName
            Me.txtPendingPowerofAttorney.Text = .PendingPowerOfAttorney
            Me.txtClientInvestorActionName.Text = .ClientInvestorActionName
            Me.txtTitleVestedintheNameof.Text = .TitleVestedInTheNameOf

            'MERS Data
            Me.txtMERSReg.Text = .MersReg
            Me.txtMERSMOMNo.Text = .MersMinNo
            Me.txtMERSMOMInd.Text = .MersMomInd

            'Property Information
            'Me.lblAddress.Text = .add
            'Me.ddlState.SelectedValue = .State
            'Insurer Information
            If Not ddlInsurer.Items.FindByValue(.Insurer) Is Nothing Then
                Me.ddlInsurer.SelectedValue = .Insurer.ToString
            Else
                Me.ddlInsurer.SelectedIndex = 0
            End If
            'Me.ddlInsurer.SelectedValue = .Insurer
            Me.txtInsurerLoanNumber.Text = .InsurerLoanNumber
        End With
        Me.pnlFileInfo.Visible = False

        Me.pnlFileEditInfo.Visible = True
    End Sub



    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim loan As ILoanInfo
        loan = Me.GetNewLoanInfo()

        With loan
            .LoanClassification = ddlLoanClassification.SelectedItem.ToString
            .LoanType = txtLoanType.Text
            .LoanPosition = ddlLoanPosition.SelectedItem.ToString
            .LoanOrigination = txtLoanOrigination.Text
            .FirstPayment = txtFirstPayment.Text
            .NextPayment = txtNextPayment.Text
            .OriginalLoanAmount = txtOriginalLoanAmount.Text
            .OriginalInterestRate = txtOriginalInterestRate.Text
            .CurrentLoanAmount = txtCurrentLoanAmount.Text
            .CurrentInterestRate = txtCurrentInterestRate.Text
            .NetAmountDue = txtNetAmountDue.Text
            .LoanTerm = txtLoanTerm.Text
            .EscrowBalance = txtEscrowBalance.Text
            .PIPayment = txtPIPayment.Text
            .PaymentFrequency = ddlPaymentFrequency.SelectedItem.ToString
            .InterestCalculationMethod = ddlInterestCalculationMethod.SelectedItem.ToString
            .SuspenseBalance = txtSuspenseBalance.Text
            .OccupancyStatus = ddlOccupancyStatus.SelectedItem.ToString
            .PostPetitionDueDate = txtPostPetitionDueDate.Text
            .Investor = ddlInvestor.SelectedItem.ToString
            .InvestorLoanNumber = txtInvestorLoanNumber.Text
            .ClientInvestorCode = txtClientInvestorCode.Text
            .InvestorCategory = txtInvestorCategory.Text
            .InvestorName = txtInvestorName.Text
            .PendingInvestorLoanNumber = txtPendingInvestorLoanNumber.Text
            .PowerOfAttorney = txtPowerofAttorney.Text
            .PendingInvestorChangeEffectiveDate = txtPendingInvestorChangeEffectiveDate.Text
            .PendingInvestorNumber = txtPendingInvestorNumber.Text
            .PendingInvestorCategory = txtPendingInvestorCategory.Text
            .PendingInvestorName = txtPendingInvestorName.Text
            .PendingPowerOfAttorney = txtPendingPowerofAttorney.Text
            .ClientInvestorActionName = txtClientInvestorActionName.Text
            .TitleVestedInTheNameOf = txtTitleVestedintheNameof.Text

            'MERS Data
            .MersReg = txtMERSReg.Text
            .MersMinNo = txtMERSMOMNo.Text
            .MersMomInd = txtMERSMOMInd.Text
            .Insurer = ddlInsurer.SelectedItem.ToString
            .InvestorLoanNumber = txtInsurerLoanNumber.Text
            .ModifiedBy = ProcMan.GetUserID(MyBase.oUser)
        End With
        Me.UpdateLoan(loan)
    End Sub
#End Region
 
Last edited by a moderator:
Um, the exception is being thrown in the UpdateLoadInfo method and you haven't posted the code for that method.

That said, you shouldn't need us to fix it for you anyway. The error message is telling you exactly what the issue is. You're accessing a List item via index and it's telling you that index has to be non-negative and less than the size of the collection. What value are you using as an index? How is it calculated? Why is it to big or too small for a valid index?
 
Back
Top