If I add a row on the client side, I can see the new row appear in my grid and I am able to make changes to the values. When I click any button that posts back to the page, I receive this null reference error:
[NullReferenceException: Object reference not set to an instance of an object.]
Infragistics.Web.UI.GridControls.EditingCore.OnAction(String actionType, Object id, Object value, Object tag) +16778
Infragistics.Web.UI.GridControls.GridBehavior.Infragistics.Web.UI.GridControls.IGridBehavior.OnAction(String actionType, Object id, Object value, Object tag) +90
Infragistics.Web.UI.GridControls.GridBot.LoadAdditionalClientState(Object state) +2187
Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent() +340
Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent() +108
Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RaisePostDataChangedEvent() +67
System.Web.UI.Page.RaiseChangedEvents() +89
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2777
On the grid I have ViewState disabled and on the Editing Core I have BathUpdating enabled. What is causing this null reference?
Here is a sample I have created for you to reproduce the error. Thank you for your help.
Hi,
The problem is in your sample. You are giving three values in the array when adding a row. However, you have only two columns, so there is a null reference exception trying to get an Item (cell) from the row on the server for the third one. This value is unnecessary. If you need a value not in the columns, you should add it in the row adding event on the server.
regards,David Young
Thank you for the quick response. I was adding that column for the datakey. If you notice in my datatable, the 3rd column is just a row number that I am using for the primary key but I am not displaying that column. I need to have a unique key and add rows on the client side. Is there a way to set the DataKey to the row number?
Hi bhughes1,I answered this already. If you need extra values that are not in the columns, you need to handle the RowAdding server event. In that event, you should be able to set another value in the hashtable that contains the added row's key/value pairs for the grid to use in the add operation.
regards,
David Young
Sorry, I didn't quite understand the first time. I have it working now. Thank you for all your help.
Hi bhughes1,
Please let me know if you need any additional assistance regarding this matter.