ArgumentOutOfRangeException for index

Specified argument was out of the range of valid values. Parameter name: index

Let me know if I'm following the right path here. OK, I'm updating a datagrid, so I need to obtain the values in the edit text boxes so I can then construct my UPDATE sql to update the record. Easy right. Well, using the following code I get the above mentioned error message:

 Dim FID As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
>Dim Fnd As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text

The .Cells(1). seems to work well but the program yaks on anything over 1.

Windows 2003, IIS 6, VB, Ole connection to Access database. Do you need to see anymore code?

I know that e.Item.Cells.Count = 7
when I add the value of i.Item.Cells(1).Controls(0) to a label I know it is the first bound column
the second bound column is sortable but read only - Is this the problem?
mfonyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ihenryCommented:

First off, do you have a condition which checking type of DataGridItem thats being process?

If e.Item.ItemType = ListItemType.AlternatingItem And e.Item.ItemType = ListItemType.Item
   ' get the textbox control here..
End If

And are you sure you have a textbox in the cell index no. 2? If you know ID of the textbox before hand, why don't use e.FindControl method instead.

Dim txt1 As TextBox = CType( e.FindControl( "theTextboxID" ), Textbox )
Dim FIN As String = txt1.Text
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.