Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Out of index error
posted

Hi,

I am getting one error ,that is

System.ArgumentOutOfRangeException was caught

  Message="Index was out of range. Must be non-negative and less than the

size of the collection. Parameter name: index"

while loading/assigning datasource to wingrid.Try...catch section is also not able to

catch this particular error.

I have gone through the site

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=5165

but where  i need to write these methods?

I tried with this code but still error is coming after trying few

 times(50 times) ,It is no so frequent error.

                grdInvestor.BeginUpdate()
             
grdInvestor.SuspendRowSynchronization()
                If grdInvestor.DataSource Is Nothing Then
                    grdInvestor.DataSource = DatabseReturnInvestor
                    grdInvestor.DisplayLayout.Bands(0).Columns("Investor").Width = 350
                    grdInvestor.DisplayLayout.Bands(0).Columns("Fund").Width = 350
                    HideExcelGridColumns(grdInvestor)
                End If
                grdInvestor.ResumeRowSynchronization()
                grdInvestor.EndUpdate()

I am also using some events like

grdInvestor_AfterRowUpdate,

grdInvestor_BeforeEnterEditMode

grdInvestor_DoubleClickRow

grdInvestor_InitializeLayout

grdInvestor_InitializeRow

grdInvestor_Click

I am attaching screen shots for reference.

Thanks in advance.

 

Regards,

Rajesh Kumar

Parents
  • 37774
    Suggested Answer
    posted

    Rajesh,

    According to your stack trace, the exception is occuring because there are no bands (i.e. bands(0) is out of range since there are no items in the array).  My guess is that since you've called BeginUpdate on the grid, the grid will not have a chance to paint or render, which usually triggers the grid to build its data structure. What I would do is put any code that needs to access columns into the InitializeLayout event of the grid instead of trying to do it directly after assigning the DataSource.  You could also try removing the Suspend/ResumeRowSynchronization calls, since I'm not sure that these really have any benefit at this point.

    -Matt

Reply Children