If a layer returns features, they are included in a System.Data.DataTable (variable named "queryResultsDataTable") which is added to a single DataSet (variable named "queryResultsDataSet"). Note that the map resource type is non-specific, therefore any data source that supports queries can be used (e.g. ArcIMS, ArcGIS Server). The DataSet can then be used as a data source for a GridView to display a table of values in a Web page.
[C#]
System.Data.DataSet queryResultsDataSet = new System.Data.DataSet();
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisFunctionality in
Map1.GetFunctionalities())
{
ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisResource =
gisFunctionality.Resource;
bool supported = gisResource.SupportsFunctionality(typeof
(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));
if (supported)
{
ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality queryFunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)
gisResource.CreateFunctionality(typeof
(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);
string[] layerIDs = null;
string[] layerNames = null;
queryFunctionality.GetQueryableLayers(null, out layerIDs, out layerNames);
ESRI.ArcGIS.ADF.Web.Geometry.Envelope adfEnvelope = new
ESRI.ArcGIS.ADF.Web.Geometry.Envelope( - 120, 30, - 100, 40);
ESRI.ArcGIS.ADF.Web.SpatialFilter spatialFilter = new
ESRI.ArcGIS.ADF.Web.SpatialFilter();
spatialFilter.Geometry = adfEnvelope;
spatialFilter.ReturnADFGeometries = true;
spatialFilter.MaxRecords = 1000;
for (int index = 0; index < layerIDs.Length; index++)
{
System.Data.DataTable queryResultsDataTable = queryFunctionality.Query
(gisFunctionality.Name, layerIDs[index], spatialFilter);
queryResultsDataTable.TableName = gisResource.Name + "_" +
layerNames[index];
queryResultsDataSet.Tables.Add(queryResultsDataTable);
}
}
}
[VB.NET]
Dim queryResultsDataSet As System.Data.DataSet = New System.Data.DataSet()
For Each gisFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality In Map1.GetFunctionalities()
Dim gisResource As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource = gisFunctionality.Resource
Dim supported As Boolean = gisResource.SupportsFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality))
If supported Then
Dim queryFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality = CType(gisResource.CreateFunctionality (GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), Nothing), ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)
Dim layerIDs As String() = Nothing
Dim layerNames As String() = Nothing
queryFunctionality.GetQueryableLayers(Nothing, layerIDs, layerNames)
Dim adfEnvelope As ESRI.ArcGIS.ADF.Web.Geometry.Envelope = New ESRI.ArcGIS.ADF.Web.Geometry.Envelope( -120, 30, -100, 40)
Dim spatialFilter As ESRI.ArcGIS.ADF.Web.SpatialFilter = New ESRI.ArcGIS.ADF.Web.SpatialFilter()
spatialFilter.Geometry = adfEnvelope
spatialFilter.ReturnADFGeometries = True
spatialFilter.MaxRecords = 1000
Dim index As Integer = 0
Do While index < layerIDs.Length
Dim queryResultsDataTable As System.Data.DataTable = queryFunctionality.Query(gisFunctionality.Name, layerIDs(index), spatialFilter)
queryResultsDataTable.TableName = gisResource.Name & "_" & layerNames(index)
queryResultsDataSet.Tables.Add(queryResultsDataTable)
index + = 1
Loop
End If
Next gisFunctionality