473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

index out of range error

When I run the following code:

private void applicationPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{

if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.Alternating Item))
{
if(applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[6].Text == "0")
{
applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[0].Text = "NO";
}
}

I get the following 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 187: (e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.Alternating Item))
Line 188: {
Line
189: if(applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[6].Text ==
"0")
Line 190: {
Line
191: applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[0].Text =
"NO";
Source File: c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs Line:
189

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) +91
System.Web.UI.WebControls.DataGridItemCollection.g et_Item(Int32 index)
DataViewer.permissionForm.applicationPermissionGri d_ItemDataBound(Object
sender, DataGridItemEventArgs e) in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:189
System.Web.UI.WebControls.DataGrid.OnItemDataBound (DataGridItemEventArgs e)
System.Web.UI.WebControls.DataGrid.CreateItem(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e)
System.Web.UI.WebControls.BaseDataList.DataBind()
DataViewer.permissionForm.FillApplicationPermissio nGrid() in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:156
DataViewer.permissionForm.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:50
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

What do I need to change to correct this?

Thanks,

Dave

Nov 16 '05 #1
2 16114
David,

you could try the following

.....
if(e.Item.Cells[6].Text == "0")
{
e.Item.Cells[0].Text = "NO";
}
......

HTH

Ollie Riches

"kscdavefl" <ks*******@discussions.microsoft.com> wrote in message
news:EA**********************************@microsof t.com...
When I run the following code:

private void applicationPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{

if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.Alternating Item))
{
if(applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[6].Text == "0")
{
applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[0].Text = "NO";
}
}

I get the following 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 187: (e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.Alternating Item))
Line 188: {
Line
189: if(applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[6].Text ==
"0")
Line 190: {
Line
191: applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[0].Text =
"NO";
Source File: c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs Line:
189

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) +91
System.Web.UI.WebControls.DataGridItemCollection.g et_Item(Int32 index)
DataViewer.permissionForm.applicationPermissionGri d_ItemDataBound(Object sender, DataGridItemEventArgs e) in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:189
System.Web.UI.WebControls.DataGrid.OnItemDataBound (DataGridItemEventArgs e) System.Web.UI.WebControls.DataGrid.CreateItem(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e)
System.Web.UI.WebControls.BaseDataList.DataBind()
DataViewer.permissionForm.FillApplicationPermissio nGrid() in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:156
DataViewer.permissionForm.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:50
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

What do I need to change to correct this?

Thanks,

Dave

Nov 16 '05 #2
Thanks a million .

"Ollie Riches" wrote:
David,

you could try the following

.....
if(e.Item.Cells[6].Text == "0")
{
e.Item.Cells[0].Text = "NO";
}
......

HTH

Ollie Riches

"kscdavefl" <ks*******@discussions.microsoft.com> wrote in message
news:EA**********************************@microsof t.com...
When I run the following code:

private void applicationPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{

if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.Alternating Item))
{
if(applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[6].Text == "0")
{
applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[0].Text = "NO";
}
}

I get the following 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 187: (e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.Alternating Item))
Line 188: {
Line
189: if(applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[6].Text ==
"0")
Line 190: {
Line
191: applicationPermissionGrid.Items[e.Item.ItemIndex].Cells[0].Text =
"NO";
Source File: c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs Line:
189

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) +91
System.Web.UI.WebControls.DataGridItemCollection.g et_Item(Int32 index)

DataViewer.permissionForm.applicationPermissionGri d_ItemDataBound(Object
sender, DataGridItemEventArgs e) in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:189

System.Web.UI.WebControls.DataGrid.OnItemDataBound (DataGridItemEventArgs e)
System.Web.UI.WebControls.DataGrid.CreateItem(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e)
System.Web.UI.WebControls.BaseDataList.DataBind()
DataViewer.permissionForm.FillApplicationPermissio nGrid() in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:156
DataViewer.permissionForm.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\dataviewer\permissionform.aspx. cs:50
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

What do I need to change to correct this?

Thanks,

Dave


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Clark Choi | last post by:
I ran the sample application called Petstore from msdn. Everything went fine until I tested Update button on the web form to update the database through Datagrid. I have been searching the web to...
1
by: Dave | last post by:
I'm getting the following error on an EditCommand event. This code is running on production web farm and the thing is it doesn't happen all the time. If I get this error, click the back button,...
2
by: Henry J. | last post by:
Has anybody run into this index out range exception when opening and then closing a collectionEditor from within a PropertyGrid? I use PropertyGrid to edit configurations in my application. One...
0
by: ssims | last post by:
I've got a GridView that's sorted by a stored procedure with ROW_NUMBER: PROCEDURE dbo.GetCalendarsByStatusIDPaged ( @startRowIndex int, @maximumRows int, @statusID int ) AS
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
6
by: arial | last post by:
Any one knows how to fix this isssue? this is the error on line: 161 Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Description:...
2
by: Georgy Panterov | last post by:
I am a relatively new python user. I am writing an economic simulation of acard-game. The simulation runs fine for a few iteration but then it gives an error of "list index out of range." The...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello As I debug the C# code with a break point and by pressing F11 I eventually get a message stating: ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from...
6
by: shashi shekhar singh | last post by:
Respected Sir, I am facing problem when i try to deploy my website on iis 7.0 on test page. i have to display some .mht files on iframe in gridview and error looks like below, Server Error in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.