I am trying to perform a foreach loop on a set of UltraDataSource.rows but I found that sometimes the addrow is included and other times it isn't. There is a property within the row called IsAddRow, but I can't access it.
Any Ideas?
Okay, if you have a solution, I am going to go ahead and close this case. Thanks for the quick reply. :)
I did not use the workaround presented, but I was able to figure it out. I am not accessing the IsAddRow Property.
Hi,
I've been investigating this issue and I'd like to get some more information from you about exactly what you need here.
The internal IsAddRow property is something of a gray area. It's internal for a reason, and that's because the UltraDataSource doesn't really have a concept of an AddRow - at least no in the same sense as the grid does. This was a flag we added solely for the purpose of dealing with what happens when you cancel an AddRow in the grid. The UltraDataSource gets a notification about the cancellation from the BindingManager and it has to know whether to cancel the changes to the existing row or delete the entire row.
So while we could, in theory, expose the IsAddRow property publicly, it would be confusing and inconsistent and I'm reluctant to do this without knowing more about the use case here.
Please let me know if the workaround (above) works for you. If not, then please provide more information about exactly what you are trying to do, and perhaps I can point you to a better solution.
Hi Doug,
The visibility of AddRow depends on when you are calling update method or what the updatemode of grid is. You can access IsAddRow property of a DataSource Row by using reflection here is a small code sample that you can use
using System.Reflection; UltraDataRow row; PropertyInfo piRow = typeof(UltraDataRow ).GetProperty("IsAddRow", BindingFlags.NonPublic | BindingFlags.Instance); row = this.ultraDataSource1.Rows[0]; piRow.GetValue(row);
bool isAddRow=(bool)piRow.GetValue(row);
You cannot access IsAddRow property of UltraDataRow because it is internal, I logged this issue with our development team so this property will be visible in future. But it is more efficient to loop through Grid Rows than Data Source Rows and you can get corresponding row from the grid and check IsAddRow property on that. Please let me know if you have any other questions.
Sincerely, Sahaja Kokkalagadda