protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { if (e.Item.OwnerTableView.Name == "Parent") { Button editLink = (Button)e.Item.FindControl("EditLink"); editLink.Attributes["href"] = "javascript:void(0);"; editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}','{2}','{3}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EID"], e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["RID"], e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["VID"], e.Item.ItemIndex); } else if (e.Item.OwnerTableView.Name == "Child") { // nothing } } if (e.Item is GridCommandItem) { if (e.Item.OwnerTableView.Name == "Parent") { Button addLink = (Button)e.Item.FindControl("AddNewRecordLink"); addLink.Attributes["href"] = "javascript:void(0);"; addLink.Attributes["onclick"] = String.Format("return ShowInsertForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EID"], e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["VID"]); } } }An exception of type 'System.ArgumentOutOfRangeException' occurredCan anyone please help me what wrong in the bold text of code block above? I tried to get DataKeyValues and assign to asp.Button on CommandItemTemplate of RadGrid1
it works in GridDataItem, but it does not work in GridCommandItem
Thanks,
Sam