Select to view content in your preferred language

problem wit result of field task

742
3
02-28-2011 05:12 AM
MarcoRosa
Emerging Contributor
Hi to all, i've an error at the end of field task, in the FindDetails_SelectionChanged of my datagrid output.
If i find a polygon or a line all works good , if i find a point i have an error on the red istruction below when i try to obtain shape type.
Maybe a spatial reference problem ? I'm using a find task on a service with a point layer inside. the layer spatial reference is 3857 and the map is 102100.
The error is "Object reference not set to an instance of an object."
What can it be ?

Thanks GP



DataGrid dataGrid = sender as DataGrid;

int selectedIndex = dataGrid.SelectedIndex;
if (selectedIndex > -1)
{
FindResult findResult = (FindResult)
_Parent.MyDataGridOutput.QueryDetailsDataGrid.SelectedItem;
Graphic graphic = findResult.Feature;

switch (graphic.Attributes["Shape"].ToString())
{
case "Polygon":
graphic.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
case "Polyline":
graphic.Symbol = _Parent.LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
case "Point":
graphic.Symbol = _Parent.LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
break;
}
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
These two spatial reference are equivalent. Does your service include Shape field for points?

Kindly check that
graphic.Attributes["Shape"]
is not null before you, call ToString() on it.
0 Kudos
MarcoRosa
Emerging Contributor
Hi Jennifer,
i have deleted the service and recreate a new one with other point , same spatial reference , same all. Strange but this works ... now im' trying other points layer and i'll see.
Thanks at the moment.
see un on other posts 🙂 have nice day
0 Kudos
ErikEngstrom
Frequent Contributor
Keep in mind that the line:
switch (graphic.Attributes["Shape"].ToString())


"Shape" is case sensitive. If you have a feature class that has the Shape field as "SHAPE" (all uppercase), you'll need to accommodate for that in your code, or else you will receive an error.
0 Kudos