I'm filling UltraGrid with a DataTable. When I try to filter, it gives an error that DBNull can't be converted to other types. Is there a way to handle this at the grid-level w/o having to check every single col and every single row?
I've got a lot of cols and a lot of rows so it would be a lot of code and would probably slow it down too much.
Hello Sean,
I recommend trying to set the Nullable property to Nullable.Null for each ultraGrid column where a null value is considered valid. If this doesn't help I recommend you send us a sample demonstrating the behavior.
Quoted from the API
"Different databases deal with null values in different ways. Since the UltraGrid is designed to work with a variety of data sources, it has the ability to query the back end and find out which way to store null values. Depending on the type of connection to the database, this can have a significant impact on performance. If you know how the database handles the storage of null values, you can improve performance by setting the Nullable property to either 1 (NullableNull) or 2 (NullableEmptyString). Setting this value to 0 (NullableAutomatic) will provide a greater range of compatibility, but performance will suffer.
If the database does not support null values, and you attempt to force the storage of nulls by setting Nullable to 1 (NullableNull), an error will result. If you encounter problems when you attempt to save a record that contains a null value, you can change the setting of Nullable which should fix the problem. In any case, you should implement error-checking code to insure that the storage operation succeeded.
The setting of this property controls how the UltraWinGrid control will attempt to store the null value. In some cases, the mechanism used for data binding may change the null value before actually committing it to the database."
Ok, so I created a dt and loaded it manually with data, and I set one of the cols to DBNull.Value. And for some reason I wasn't able to repro the issue when filtering.
I even made sure that the data types were definitely coming through the same in both projects. And they are. So the question is, what setting would there be through the designer that would effect this?
I've pasted the grid from the other project and it doesn't repro in the new project either. And I've disabled a bunch of stuff in the orig project like styles, and some error handling, etc and it still errors when I filter.
Thanks for the advice. I tried what you said with no success. I'm setting this in the initialize layout method.
UltraGridColumn column = RWGrid.DisplayLayout.Bands[0].Columns["SQLVersion"]; column.Nullable = Infragistics.Win.UltraWinGrid.Nullable.Null;
I've also tried Nothing and EmptyString.
I've also tried setting all cols.
ColumnsCollection columns = grid.DisplayLayout.Bands[0].Columns;
foreach (UltraGridColumn c in columns) { c.Nullable = Infragistics.Win.UltraWinGrid.Nullable.Null; }
I'll see if I'm able to repro it with a manual DataTable.