Click here to Skip to main content
15,896,912 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Just trying to get simple app to run on the server Pin
Abhijit Jana23-Jul-09 10:30
professionalAbhijit Jana23-Jul-09 10:30 
GeneralRe: Just trying to get simple app to run on the server Pin
Jeffrey Webster23-Jul-09 11:30
Jeffrey Webster23-Jul-09 11:30 
AnswerRe: Just trying to get simple app to run on the server Pin
Abhijit Jana23-Jul-09 11:44
professionalAbhijit Jana23-Jul-09 11:44 
GeneralRe: Just trying to get simple app to run on the server Pin
Jeffrey Webster23-Jul-09 12:41
Jeffrey Webster23-Jul-09 12:41 
GeneralRe: Just trying to get simple app to run on the server Pin
Jeffrey Webster23-Jul-09 13:18
Jeffrey Webster23-Jul-09 13:18 
GeneralRe: Just trying to get simple app to run on the server Pin
Abhijit Jana23-Jul-09 19:45
professionalAbhijit Jana23-Jul-09 19:45 
QuestionASP authentication for WCF Pin
hb5213421423-Jul-09 6:34
hb5213421423-Jul-09 6:34 
QuestionGridView....Index Out Of Range Exception....PLEASE HELP ! Pin
PDTUM23-Jul-09 6:22
PDTUM23-Jul-09 6:22 
Gentleman:

I have posted this issue at several sites and received some very useful code, ranging from 2 lines to a dozen, on how to retrieve row and cell information from a GridView. Thanks to all of you. That being said, the original issue was that I was (am) receiving an "Index Out of Range" exception error. The CommandArgument correctly reports the selected row. This happens regardless of which string of code I am using. Now, I know that only a few developers really understand the stack trace (and I am not one of them), but because I have not been able to understand the reason for the error, I am posting the entire error and stack trace for all to see. I am hopeful that one of you geniuses out there will be able to determine the exact cause of the error. For my part, it appears that the System.Collection array is predetermined by the GridView and is automatically passed along. I cannot understand how or why I can get this error, since there are always a positive number of rows. My entire application has been stopped for a week due to this error. PLEASE.....HELP if you can. All suggestions are greatly appreciated. This is certainly over my head. Thanks in advance to all that have sent in code and especially to person that can finally solve this dilemma......Pat

MY Code:

//Define the row and cell
int theRow = Convert.ToInt32(e.CommandArgument);
int theCell = 5;

//Get the Row information
GridViewRow gvr = (GridViewRow)GridViewResults.Rows[theRow]; //THE ERROR REPORTS ON THIS LINE

//Get the information from the cell
string thePdf = gvr.Cells[theCell].Text;

//Pass the pdf information, start the users Pdf Reader
Process.Start(thePdf);


The Complete Error:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
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.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Source Error:

Line 481:
Line 482: //Get the Row information
Line 483: GridViewRow gvr = (GridViewRow)GridViewResults.Rows[theRow];
Line 484:
Line 485: //Get the information from the cell


Source File: c:\Documents and Settings\Patrick Tuminaro\My Documents\Visual Studio 2008\WebSites\TB_09_Online\Main.aspx.cs Line: 483

Stack Trace:

[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.Collections.ArrayList.get_Item(Int32 index) +7485640
System.Web.UI.WebControls.GridViewRowCollection.get_Item(Int32 index) +13
Main.GridViewResults_RowCommand(Object sender, GridViewCommandEventArgs e) in c:\Documents and Settings\Patrick Tuminaro\My Documents\Visual Studio 2008\WebSites\TB_09_Online\Main.aspx.cs:483
System.Web.UI.WebControls.GridView.OnRowCommand(GridViewCommandEventArgs e) +108
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +112
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +207
System.Web.UI.WebControls.GridView.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) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
AnswerRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
Abhijit Jana23-Jul-09 10:35
professionalAbhijit Jana23-Jul-09 10:35 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
PDTUM23-Jul-09 10:50
PDTUM23-Jul-09 10:50 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
Abhijit Jana23-Jul-09 11:04
professionalAbhijit Jana23-Jul-09 11:04 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
PDTUM23-Jul-09 11:12
PDTUM23-Jul-09 11:12 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
Abhijit Jana23-Jul-09 11:35
professionalAbhijit Jana23-Jul-09 11:35 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
PDTUM23-Jul-09 11:46
PDTUM23-Jul-09 11:46 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
Abhijit Jana23-Jul-09 12:03
professionalAbhijit Jana23-Jul-09 12:03 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
PDTUM23-Jul-09 12:26
PDTUM23-Jul-09 12:26 
AnswerRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
PDTUM23-Jul-09 13:13
PDTUM23-Jul-09 13:13 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
Abhijit Jana23-Jul-09 19:47
professionalAbhijit Jana23-Jul-09 19:47 
AnswerRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
Ravi Kakumani13-Aug-09 5:14
Ravi Kakumani13-Aug-09 5:14 
GeneralRe: GridView....Index Out Of Range Exception....PLEASE HELP ! Pin
PDTUM13-Aug-09 6:46
PDTUM13-Aug-09 6:46 
Questionconnect a ROW of database to MSCHART in asp.net Pin
solo_gaurav23-Jul-09 6:06
solo_gaurav23-Jul-09 6:06 
AnswerRe: connect a ROW of database to MSCHART in asp.net Pin
Abhijit Jana23-Jul-09 6:18
professionalAbhijit Jana23-Jul-09 6:18 
GeneralRe: connect a ROW of database to MSCHART in asp.net Pin
solo_gaurav23-Jul-09 6:21
solo_gaurav23-Jul-09 6:21 
GeneralRe: connect a ROW of database to MSCHART in asp.net Pin
solo_gaurav23-Jul-09 6:41
solo_gaurav23-Jul-09 6:41 
GeneralRe: connect a ROW of database to MSCHART in asp.net Pin
Abhijit Jana23-Jul-09 6:43
professionalAbhijit Jana23-Jul-09 6:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.