Hi Team,
I have a webdata grid with a bound checkbox coloum (column added to datatable ) and based on selection of checkbox, I am removing the records from the database,
This part is taking place in RowUpdating server side event.
At the end of the rowupdating method, I am re-binding the grid.
Doing so I am getting error ' not set to an instance of an object.",
Below is the detailed stack trace message.
at Infragistics.Web.UI.GridControls.ControlDataRecordCollection.MarkRecordChange(Int32 index) at Infragistics.Web.UI.GridControls.ControlDataRecord.NotifyPropertyChange() at Infragistics.Web.UI.GridControls.ControlDataItem.NotifyPropertyChange() at Infragistics.Web.UI.GridControls.GridRecordItem.set_Text(String value) at Infragistics.Web.UI.GridControls.EditingCore.OnAction(String actionType, Object id, Object value, Object tag) at Infragistics.Web.UI.GridControls.GridBehavior.Infragistics.Web.UI.GridControls.IGridBehavior.OnAction(String actionType, Object id, Object value, Object tag) at Infragistics.Web.UI.GridControls.GridBot.LoadAdditionalClientState(Object state) at Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent() at Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent() at Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RaisePostDataChangedEvent() at System.Web.UI.Page.RaiseChangedEvents() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Any idea why I am getting this error
If I need to do so that I need to rebind the grid after rowupdating event that is removing some data from database, how can i do that?
Regards
Varun
Hello,
I am still following up. Have you been able to resolve the issue?If you have any concerns or questions, please feel free to contact me, I will be glad to help you.Thank you for choosing Infragistics components!
Hi Denis,
Thanks for the follow up..
Yes. I managed to solve the problem.
What I found that I was getting this error '..RecordCollection.MarkRecordChange(Int32 index)' only when I mark a record for delete and handle that at server side.
In my scenario, delete was handled a bit differently. I have soft delete (that is a delete flag in table to mark a row deleted).
So users need to select/unselect checkbox to do so. Changing checkbox values marks the same as updated row and I am handling this on _RowUpdating server side event.
Now what was happening is that once I set delete flag to true, the data source does not return the record.
I was doing databind on rowUpdating as well. Since the new data source does not contains records updated (that is marked for delete) , grid was not able to call the method RecordCollection.MarkRecordChange sicne that row index is not there any more
Also what I found that this error was coming only when I delete rows at end and not at top. Reason being, say I have 10 record (index 0-9), If I delete 9th and 10th record (index 8th, 9th), when grid rebinds there are only 8 records and it is calling method MarkRecordChange to mark records with index 8th and 9th. It is not finding the same and giving the error 'Instance not set to an object'..
When I am deleting 1st or 2nd row (index 0 and 1), on rebind , grid still finds rows at index 0 and 1 (though the rows are different) and it is not giving the error.
Solution:
Do not rebind the grid on _RowUpdating, RowAdding or RowDeleting.
I am rebinding the grid on Page_PreRender event and it is working fine.