Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.IndexOutOfRangeException: There is no row at position 'xx'

Status
Not open for further replies.

Maven4Champ

Technical User
Jun 16, 2004
154
I am receiving this error at position 330 in my loop. Here is the code:

Code:
Dim excludedList As New ArrayList()

                For Each dr As DataRowView In dv1
                    excludedList.Add(dv1.Table.Rows(x).Item(0).ToString)
                    x = x + 1
                Next

It errors at position 330 at this part of the code. Any ideas what causes this? Is it because of an Out of Range of the array error and if so, how to prevent it?

Thanks!
 

Try this:

Dim excludedList As New ArrayList()

For Each dr As DataRowView In dv1
excludedList.Add([red]dr[/red].Item(0).ToString)
Next

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
jebenson,

Looks like that works better - thank you. Another lead-in question with this result.

Nothing is happening in my loop after reading those records and comparing... I have tried Response.Write() but it only returns one record and taking that out never yields the results I expect.

I am using the dv1 (a dataview of responsibility_keys) with a gridview of records that hold a value of a similar responsibility_key. When I go through my loop, I compare with a FOR EACH ex IN excludedList (my array list I posted earlier).

My problem is that is feels (or at least seems like) there is only one record being passed in.

Can I post a sample of my code and get your thoughts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top