aafgilbert01

how to dinamically set the FeatureDataGrid to a feature layer

Discussion created by aafgilbert01 on Jan 28, 2013
Latest reply on Feb 1, 2013 by aafgilbert01
Hello,

I am working on a map to display the feature dataset information using the featuredatagrid. So far, I have been able to query a layer, store the query result in a graphic layer. From that graphic layer, I have assigned the following property and I am able to see the the table details of the selected objects in the layer. I use the following code to do the work.

MyDataGrid.GraphicsLayer = graphicsLayer

What I would like to offer also would be to allow the user to have acces to the whole feature layer in terms of table description . I would like to dynamically chose from my comboxbox the layer and display all the features that belong to the feature layer.

Private Sub MyDrawSurface_DrawComplete(sender As Object, args As ESRI.ArcGIS.Client.DrawEventArgs)
            Dim selectionGraphicslayer As GraphicsLayer = TryCast(MyMap.Layers("MySelectionGraphicsLayer"), GraphicsLayer)

            selectionGraphicslayer.ClearGraphics()

            Dim queryTask As New QueryTask()
            queryTask.Url = _MapService.UrlMapService & "/" & _sSelectedLayerID

            AddHandler queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompleted
            AddHandler queryTask.Failed, AddressOf QueryTask_Failed
            Dim resultFeaturesBinding As New Binding("LastResult.Features")
            resultFeaturesBinding.Source = queryTask
            Dim query As Query = New ESRI.ArcGIS.Client.Tasks.Query()
            'query.OutFields.AddRange(New String() {"STATE_NAME"})
            query.OutFields.AddRange(New String() {"*"})   ' * prend toutes les colonnes
            query.Geometry = args.Geometry
            query.ReturnGeometry = True
            queryTask.ExecuteAsync(query)
            _oMyDrawObject.IsEnabled = False

        End Sub

Private Sub QueryTask_ExecuteCompleted(sender As Object, args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
            Dim featureSet As FeatureSet = args.FeatureSet
            Dim sOJBID As String = ""

            If featureSet Is Nothing OrElse featureSet.Features.Count < 1 Then
                MessageBox.Show("La sélection n'a retourné aucuns objets")
                Return
            End If
            Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MySelectionGraphicsLayer"), GraphicsLayer)

            MyMapTip.GraphicsLayer = graphicsLayer  'to remove
            MyDataGrid.GraphicsLayer = graphicsLayer  'to remove

            If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then
                For Each feature As Graphic In featureSet.Features
                    Select Case featureSet.GeometryType
                        Case GeometryType.Polygon
                            feature.Symbol = TryCast(LayoutRoot.Resources("DefaultFillSymbol"), FillSymbol)
                            Exit Select
                        Case GeometryType.Polyline
                            feature.Symbol = TryCast(LayoutRoot.Resources("DefaultLineSymbol"), LineSymbol)
                            Exit Select
                        Case GeometryType.Point
                            feature.Symbol = TryCast(LayoutRoot.Resources("DefaultMarkerSymbol"), MarkerSymbol)
                            Exit Select
                    End Select
                    'feature.Symbol = TryCast(LayoutRoot.Resources("ResultsFillSymbol"), FillSymbol)
                    graphicsLayer.Graphics.Insert(0, feature)

                    sOJBID = sOJBID & "OBJECTID= " & feature.Attributes.Values(0).ToString & ", " & feature.Attributes.Values(1).ToString & vbLf
                Next
                'MessageBox.Show(sOJBID)
            End If

            _oMyDrawObject.IsEnabled = False
        End Sub

Outcomes