I have setup a hierarchical grid by manually databinding the grid to a hierarchical LLBLGen Pro EntityCollection. I have created the UpdateRow event to handle Add and Update functionality. Everything was working fine until I added a third band to the grid and the code to Add, Update the third band. Now for some reason only the third band won't work because of a null reference exception which I can't figure out. Can somone look at the attached code in the zip and try to explain why the JobCrewTime band won't work?
I wanted to add to my original post more information about where I get the null reference exception. I think it's important because there are two almost identical lines where one works and one does not work.
There is a comment at the end of each line where one works and one doesn't.
else if (row.Band.Key == "Jobs"){ JobEntity job = new JobEntity(); job.JobOrderId = (int)row.ParentRow.Cells.FromKey("JobOrderId").Value; THIS IS WHAT WORKS foreach (UltraGridCell cell in row.Cells) { if (cell.DataChanged) { string fieldName = cell.Column.BaseColumnName; object value = cell.Value; job.SetNewFieldValue(fieldName, value); } } ServiceManager.GetPersistanceManager().SaveEntity(job, true);}
This one does not work.
else if (row.Band.Key == "JobCrewTime"){ if (!row.ParentRow.Cells.Exists("JobId")) return; JobCrewTimeEntity jobCrewTime = new JobCrewTimeEntity(); jobCrewTime.JobId = (int)row.ParentRow.Cells.FromKey("JobId").Value; // THIS DOES NOT WORK, WHY? foreach (UltraGridCell cell in row.Cells) { if (cell.DataChanged) { string fieldName = cell.Column.BaseColumnName; object value = cell.Value; jobCrewTime.SetNewFieldValue(fieldName, value); } } ServiceManager.GetPersistanceManager().SaveEntity(jobCrewTime, true);}
I don't understand what happend. This problem has resolved itself. One thing about this grid that I keep having a problem with this that features seem to stop and start working and I have no idea why. It does bother me.