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