Answered by:
System.IndexOutOfRangeException: There is no row at position 98.

Question
-
hi Im try to import data from excel sheet to my sql server database
I get the following error
There is no row at position 98.
Exception Details: System.IndexOutOfRangeException: There is no row at position 98.
Source Error:
Line 84: Line 85: For i As Integer = 0 To DirectCast(e.Item.FindControl("ddlteacher"), DropDownList).Items.Count - 1 Line 86: If DirectCast(e.Item.FindControl("ddlteacher"), DropDownList).Items(i).Text.ToLower() = Topic.Tables(0).Rows(k)("TEACHERNAME").ToString().ToLower() Then Line 87: DirectCast(e.Item.FindControl("ddlteacher"), DropDownList).Items(i).Selected = True Line 88: i = DirectCast(e.Item.FindControl("ddlteacher"), DropDownList).Items.Count
Source File: C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\visual studio\cstsWebSetup1\blkinstchtrained.aspx.vb Line: 86
Stack Trace:the code full code is below
If
Then
'Try
), DataSet)
"TEACHERNAME"
"TEACHERID"
), DropDownList).DataBind()
), DropDownList).Items.Count - 1
Then
True
i =
DirectCast(e.Item.FindControl("ddlteacher"), DropDownList).Items.Count
If
Next
), DataSet)
"Coursename"
"trcrseid"
), DropDownList).DataBind()
), DropDownList).Items.Count - 1
Then
True
i =
DirectCast(e.Item.FindControl("ddltrtype"), DropDownList).Items.Count
If
Next
Then
"YES"
Then
"NO"
If
Then
"YES"
Then
"NO"
If
Then
"YES"
Then
"NO"
If
k += 1
'Catch ex As Exception
' MsgBox(ex.Message)
'End Try
If
- Moved by Mark Liu-lxf Tuesday, November 1, 2011 6:02 AM ASP.net (From:Visual Basic General)
Thursday, October 27, 2011 11:07 AM
Answers
-
When do you get this, I've the idea you don't have the statement
If IsPostBack not before your code and is this at initializing when the viewstate is still empty.
VB for VSN samples on this official page
http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback.aspx
Success
Cor- Proposed as answer by Ed Price - MSFTMicrosoft employee Friday, November 4, 2011 2:54 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 16, 2011 8:34 PM
Thursday, October 27, 2011 3:37 PM -
Hi salongoJK,
Welcome to the MSDN forum.This queue is about Visual Basic. I’m afraid that your topic about ASP.Net is off topic here. For better support, I will move this thread to off topic forum. You can post this thread to the correct forum and here is the link: http://forums.asp.net/ . Sorry for any inconvenience.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Proposed as answer by Ed Price - MSFTMicrosoft employee Friday, November 4, 2011 2:54 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 16, 2011 8:34 PM
Tuesday, November 1, 2011 6:01 AM
All replies
-
When do you get this, I've the idea you don't have the statement
If IsPostBack not before your code and is this at initializing when the viewstate is still empty.
VB for VSN samples on this official page
http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback.aspx
Success
Cor- Proposed as answer by Ed Price - MSFTMicrosoft employee Friday, November 4, 2011 2:54 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 16, 2011 8:34 PM
Thursday, October 27, 2011 3:37 PM -
Hi salongoJK,
Welcome to the MSDN forum.This queue is about Visual Basic. I’m afraid that your topic about ASP.Net is off topic here. For better support, I will move this thread to off topic forum. You can post this thread to the correct forum and here is the link: http://forums.asp.net/ . Sorry for any inconvenience.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Proposed as answer by Ed Price - MSFTMicrosoft employee Friday, November 4, 2011 2:54 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 16, 2011 8:34 PM
Tuesday, November 1, 2011 6:01 AM