Select to view content in your preferred language

FeatureDataGrid does not display rows with null values as of version 2.2

854
6
07-29-2011 01:41 AM
stefanschlaefli
Regular Contributor
Since Version 2.2 the feature data grid does not display rows containing null values anymore. A Silverlight error is raised instead:

Unhandled Error in Silverlight Application All rows must be of type 'System.Nullable`1[System.Double]' for the 'DiffPct' attribute.   at ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid.AllAttributesMatch(PropertyInfo[] itemsSourceProperties, IDictionary`2 graphicAttributes)
   at ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid.UpdateItemsSource(Object sender, NotifyCollectionChangedEventArgs e)
   at ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid.Graphics_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   at ESRI.ArcGIS.Client.GraphicCollection.InsertItem(Int32 index, Graphic item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at ESRI.ArcGIS.Client.FeatureLayer.addGraphic(Graphic g)
   at ESRI.ArcGIS.Client.FeatureLayer.task_QueryComplete(Object sender, QueryEventArgs args)
   at ESRI.ArcGIS.Client.Tasks.QueryTask.OnExecuteCompleted(QueryEventArgs args)
   at ESRI.ArcGIS.Client.Tasks.QueryTask.<>c__DisplayClass6.<request_Completed>b__4(FeatureSet fs, Exception ex)
   at ESRI.ArcGIS.Client.Tasks.FeatureSet.<>c__DisplayClass2.<FromJsonAsync>b__0(Object s, RunWorkerCompletedEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
   at System.ComponentModel.BackgroundWorker.<OnRun>b__1(Object state)

An example of a typical Binding of type DataGridTextColumn is this one:

    <my:DataGridTextColumn Binding="{Binding DiffPct, TargetNullValue='0', StringFormat=\{0:P2\}}"  Width="130"  Header="% Change" CanUserSort="True" />


Prior to toolkit version 2.2 it would just work.
0 Kudos
6 Replies
ChristopherHill
Deactivated User
Unhandled Error in Silverlight Application All rows must be of type 'System.Nullable`1[System.Double]' for the 'DiffPct' attribute.


The error message you posted says that it expected all the values to be of type Nullable.Double but at least one of the rows in column DiffPct was of a different data type. Are you loading data from a binding to a featurelayer? if DiffPct is a double type then all values have to be of type double if it finds a row that has an integer then you will get the above exception you posted.

you can use this public service to see that you can indeed have null data, but that is not the problem based on the error you provided.
http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer...
0 Kudos
stefanschlaefli
Regular Contributor
Thanks for answering Chris. Yes I'm loading data from a feature layer. DiffPct is an output field of the feature layer. it points to a sql server table and the sql data type of the DiffPct Column is float, null. Therefore the DiffPct column will always contain double values or null values. DiffPct is a calculated column (difference of two years values as percent).

If the error message is due to the fact that some value is not null or not double, why did it all work with API version 2.1? I did not change the binding or anything that is used with the feature data grid.
0 Kudos
ChristopherHill
Deactivated User
Have you tried loading the application with 2.1 again and seeing if the problem goes away to confirm that this is caused by 2.2? Have you tried looping through the graphics attributes and look at each Graphic.Attributes["DiffPct"].GetType() to determine that they are all of type double.
0 Kudos
stefanschlaefli
Regular Contributor
Yes, I rolled back to version 2.1 and the problem was gone. I didn't test every single graphic's DiffPct for it's type yet.
0 Kudos
ChrisLampe
New Contributor
I am also experiencing the same problem.  I have loaded the graphics layer from MapIT and when I assign it to the data grid in code i.e.:
MyDataGrid.GraphicsLayer = gLayer
an exception is thrown detailing that not all rows are of the expected type (varies depending on the data received from MapIT).  It generally appears to be associated with columns that have NULL data. 
If I drop back to 2.1 the problem goes away.
0 Kudos
stefanschlaefli
Regular Contributor
Just for the record: this issue seems to have disappeared in API version 2.3.
0 Kudos