Hi
I have an ultragrid which I allow group by on. I also allow updating, deleting and inserting which gives me a null reference error. I'm not sure why and I've considered disabling the buttons on the group by event which I was able to do (example a). But when the group by is turned off how is there a better way to trap that?
Is it common practive to NOT allow Insert/Update/Delete when grouping? If so, Is there a better way to disable it?
Example A)
Hi Tony,
I can't think of any reason why you shouldn't be able to delete rows when grouping. Adding rows might be a little tricky, since you have to make sure you populate whatever field is used for the grouping, but that's not really a big deal.
How are you allowing the adding of new rows? Are you setting AllowAddNew? What setting are you using? Does the TemplateAddRow show up if you use one of the TemplateAddRow settings?
Hi (I have another question about dropdown lists but I think I should post that separately).
The group by is a "nice to have" but I wanted to try it. On the Insert I get "Can't add a row to group-by rows collection.". On the update I get "Object reference not set to an instance of an object". Also, I don't mind disabling the insert/delete buttons while in group by mode which I can do, but not having luck re-enabling on UNgroup by.
Tony Licitra said:Insert:UltraGridRow newRow = UltraGridList.DisplayLayout.Bands[0].AddNew();Error:Can't add a row to group-by rows collection.
Okay... that error message seems pretty clear. You could get around that easily enough by simply adding the new row directly to your data source instead of through the grid.
Tony Licitra said: Update:foreach (UltraGridRow UGRow in UltraGridList.Rows)Error:Object reference not set to an instance of an object. UltraGridList.UpdateData(); foreach (UltraGridRow UGRow in UltraGridList.Rows) { if (CheckDBNull.ConvertToString(UGRow.Cells["MYFIELD"].Value).Trim().Length.Equals(0)) {
Clearly an object that is null and you are trying to access properties off of a null object. No way I can tell what that might be just from looking at a snippet like this, but you should be able to see what object is null here by debugging it.