Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
[IndexOutOfRangeException: Index 0 is either negative or above rows count.]
System.Data.DataView.GetRow(Int32 index) +4815691
System.Data.DataView.get_Item(Int32 recordIndex) +12
Teletrain._default1.GetUSerInfo(Int32 SelectedWeek) +4951
Teletrain._default1.Page_Load(Object sender, EventArgs e) +1216
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Posted
Comments
Kenneth Haugland 25-Jan-15 17:17pm    
Lets see the code. Is there elements in the collection or is it empty?
ZurdoDev 25-Jan-15 21:12pm    
The error is pretty clear, isn't it? What is your question?

1 solution

It is obvious that your DataView has no rows in it. You try to access the first row (index 0) but as none exists you get a 'index-out-of-range' error...
If you would expect data you should check why it didn't came...
In any case you should add a check to your code to see if there are any rows before you try to access one (any) of them...
C#
if(DataView.Count > 0)
{
  DataView.Item[0]...
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900