Click here to Skip to main content
13,193,650 members (59,438 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi everyone,

I've got following error:


There is no row at position 255. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
 
Exception Details: System.IndexOutOfRangeException: There is no row at position 255.
 
Source Error: 
 

Line 263:                    {
Line 264:
Line 265:                        dt_gridcom.Rows[s][k] = summary;
Line 266:                        if (summary.Length > 25)
Line 267:                   dt_grid.Rows[s][k] = summary.Substring(0, 25) + "...";
 
 
Source File: d:\Maestro\code\planning.aspx.cs    Line: 265 
 
Stack Trace: 
 

[IndexOutOfRangeException: There is no row at position 255.]
   System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) +115
   System.Data.RBTree`1.get_Item(Int32 index) +19
   System.Data.DataRowCollection.get_Item(Int32 index) +12
   code_planning.btshow_click(Object sender, EventArgs e) in d:\Maestro\code\planning.aspx.cs:265
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +78
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +100
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2862



this error comes from the fact when I try to show a gridview whose data given by database.


could anyone tell what kind of error is this? how to solve it?

many thanks,
Posted 13-Sep-12 5:25am
Comments
jessicachen12 13-Sep-12 11:28am
   
the error comes from Line 265.
Wes Aday 13-Sep-12 11:28am
   
The error is perfectly clear. Only try and show data for rows that actually exist. What seems to be the problem?
learner'sbug 13-Sep-12 11:41am
   
make sure that DataRowCollection is not empty.
sjelen 13-Sep-12 12:53pm
   
Since this is happening on postback, make sure you have populated datatable before reaching this code.
If you're not keeping datatable in Session, you'll need to fill it with data again on postback.
Provide more code using "Improve Question".

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

[IndexOutOfRangeException: There is no row at position 255.]
There would be defined number of rows in your grid.

It looks like value of 's' is more then the row count.
dt_gridcom.Rows[s][k] = summary;

Make sure that the row number that you are trying to access exists.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.171018.2 | Last Updated 13 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100