Select to view content in your preferred language

How to convert QueryTaskResult to datatable

2018
1
09-01-2011 09:33 AM
SubashShrestha
New Contributor
Requirement: While loading the page, I need to fill up the combo box with building numbers. Therefore, i used query task.
My concern: Is there any way so that we can convert query task result to datatable without looping the featureset.
Private Sub QueryTask_ExecutComplete(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
{
Dim enumGraphics = From g In args.FeatureSet
                               Order By (TryCast(g.Attributes("BLDNBR"), String)) Ascending
                               Select g
Dim _BuildingList As New List(Of BuildingInfo)
   For Each gn As Graphic In enumGraphics
    _Building = New BuildingInfo() With {.BLDRECNBR = gn.Attributes("BLDRECNBR").ToString, .BLDNBR = gn.Attributes("BLDNBR").ToString}
      _BuildingList.Add(_Building)
    Next
}   
I would like to eliminate the above for loop. In ASP.NET we used to do as below.
Dim queryResultsDataTable As System.Data.DataTable = Nothing
queryResultsDataTable = commonQueryFunctionality.Query(commonQueryFunctionality.Name, layerIDs(i), adfQueryFilter)

Really appreciate your help.
0 Kudos
1 Reply
dotMorten_esri
Esri Notable Contributor
You should be able to do that using a custom ItemTemplate on your combobox. Set the combobox.ItemsSource=args.FeatureSet.
Then create a custom ItemTemplate that tells the combobox how to fetch the display values from each feature. Something along the lines of:
<ComboBox>
  <ComboBox.ItemTemplate>
       <DataTemplate>
          <TextBlock Text="{Binding Attributes[BLDRECNBR]}" />
       </DataTemplate>
  </ComboBox.ItemTemplate>
</ComboBox>
0 Kudos