Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Joel Finkel #1
DataGrid1.DataKeys[e.Item.ItemIndex] array index out of bounds
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
[email]finkel@sd-il.com[/email]
Joel Finkel Guest
-
#40513 [NEW]: Notice: Unknown: List index out of bounds (0) (errflg=2) in Unknown on line 0
From: wil at codeciti dot com Operating system: WinXP PHP version: 5.2.1 PHP Bug Type: IMAP related Bug description: ... -
e.Item.ItemIndex and e.Item.DataSetIndex
When writing the update event handler for a web forms DataGrid, I am running into a situation that is giving me quite the headache! If a user has... -
DataKeys(Index): Scope issue
I can access the dg's DataKeys values (table primary key values) from events raised by objects outside of the dg. For example, from a... -
Finding Row Index for an item in a datagrid.
protected void SearchRowIndex() { string _RowIndex = null; foreach(DataGridItem di in dgd1.Items) { -
how to get datagrid item index from DataKeyField value?
Can I not use loop? Is it a simple way to do it? Thanks. -
Joel Finkel #2
Re: DataGrid1.DataKeys[e.Item.ItemIndex] array index out of bounds
Many thanks!
"Prasad" <prasadh_ms@hotmail.com> wrote in message news:ebbJcjqcDHA.3520@tk2msftngp13.phx.gbl...
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" <finkel@sd-il.com> wrote in message news:OF7mjKpcDHA.2572@TK2MSFTNGP12.phx.gbl...
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
[email]finkel@sd-il.com[/email]
Joel Finkel Guest



Reply With Quote

