Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

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?
0
mfony
Asked:
mfony
1 Solution
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now