Hello - I've got a pretty complex RadGrid mostly working, except for one case. In this case, when the user clicks a button, I change a hidden field, rebind the grid (which produces a slightly different recordset, adding one row), and I want to select that particular row and put it in edit mode.
Exception Details:System.NullReferenceException: Object reference not set to an instance of anobject.
Source Error:
Stack Trace:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
switch (e.CommandName) |
{ |
case "New": hdnForceBlankShiftForEmployeeID.Value = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EmployeeID"].ToString(); |
RadGrid1.Rebind(); |
Hashtable dictionary = new Hashtable(2); |
dictionary.Add("EmployeeID",Convert.ToInt32(hdnForceBlankShiftForEmployeeID.Value)); |
dictionary.Add("EmployeeShiftID",System.DBNull.Value); |
GridDataItem[] myArray = RadGrid1.MasterTableView.FindItemsByKeyValues(dictionary); |
if (myArray.Length> 0) |
{ |
myArray[0].Edit = true; |
} |
break; |
} |
} |
However, when I do this, I get the error below. It's coming from setting the .Edit = true, as if I comment that out, it all works (other than the record not being in edit mode, of course). Oh, incidentally, I don't have an onprerender - it's just whatever the base functionality is.
Object reference not set to an instance of an object.
Description:An unhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about the error andwhere it originated in the code.Exception Details:System.NullReferenceException: Object reference not set to an instance of anobject.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
|