This is becoming very frustrating now! I do want to say thank you Samu for your help though, but now I am completely lost. I have never had this type of problem before.
I have tried to retrieve the data in Read-Only, and Edit mode. In addition to using this code when retrieving a field in EditItemTemplate.
Dim z As String z = CType(gvEmployees.Rows(0).Cells(1).FindControl("TextBox1"), TextBox).Text
I also tried to use this code when retrieving a field within a ItemTemplate.
Dim t As String
t = CType(dvEmployees.Rows(0).Cells(1).FindControl("Label1"), Label).Text
This also failed to produce results.
I have also tried changing the index within the rows and cells, and still the same error message.
I even started over from the beginning and created a new SqlDataSource with less fields and a GridView instead of a DetailsView.
I still get the same error message! I went back to my database to review the data, and there are no Null values, or spaces, plus I have no problems when I want to edit these fields. I can modify a record using both a DetailsView and a GridView without any issues. However, when I try to store the value into a variable I get this error message.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Plus I even tried a different field to make sure there were no problems with the data type.
For example, originally I wanted to grab a field that holds a date. This date will be stored in a String variable called ‘z’ if you look at the code above. So to check that there were no problems with the data type I switch the field to grab another field that stores a name that is basically a char value, and I still get the same error message.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
What else can it be????