Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > DataGrid1.DataKeys[e.Item.ItemIndex] array index out of bounds

Reply
Thread Tools

DataGrid1.DataKeys[e.Item.ItemIndex] array index out of bounds

 
 
Joel Finkel
Guest
Posts: n/a
 
      09-04-2003
Folks,

Can someone please explan why this this line of code works fine when executed within an ItemCommand (that is, once the data are fully bound), but throws an exception when it is executed withn an ItemBound (when the data are being bound to the grid)? The exception is an array out of bounds.

string strID = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();

Thanks in advance.

Joel Finkel





 
Reply With Quote
 
 
 
 
Joel Finkel
Guest
Posts: n/a
 
      09-04-2003
Many thanks!

"Prasad" <> wrote in message news:...
Hi

You need to check the ItemType before using the Statement. Try this :

if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string strID = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
}



HTH
Prasad
"Joel Finkel" <> wrote in message news:...
Folks,

Can someone please explan why this this line of code works fine when executed within an ItemCommand (that is, once the data are fully bound), but throws an exception when it is executed withn an ItemBound (when the data are being bound to the grid)? The exception is an array out of bounds.

string strID = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();

Thanks in advance.

Joel Finkel





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: list index out of bounds 1 error wha??? rf Computer Support 3 07-27-2009 07:00 PM
Custom MembershipProvider Index out of bounds/machineKey Mark Olbert ASP .Net 1 01-25-2006 06:46 AM
Catching vector index out of bounds Biff C++ 4 01-31-2005 05:55 AM
Index out of bounds question Method Man C Programming 26 10-22-2004 06:08 PM
Re: Index Out of Bounds Error =?Utf-8?B?ZHdlbndhQGNvbXBhbnlhYmMuY29t?= ASP .Net 0 10-20-2004 06:43 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57