Finding a string in the attributes of a layer
All successful searches in a feature layer are stored in a corresponding System.Data.DataTable in the DataTable array (the "queryResultsDataTableArray" variable) returned from a call to Find().
The map resource type is non-specific; therefore, any data source that supports queries can be used (for example, ArcIMS or ArcGIS for Server).
See the following code example:
[C#]
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);
System.Collections.Generic.Dictionary < object, string = ""[] > fieldsDictionary
= new System.Collections.Generic.Dictionary < object, string = ""[] > ();
foreach (string layerID in layerIDs)
{
string[] fieldsArray = queryFunctionality.GetFields(null, layerID);
fieldsDictionary.Add(layerID, fieldsArray);
}
ESRI.ArcGIS.ADF.Web.FindParameters findParameters = new
ESRI.ArcGIS.ADF.Web.FindParameters();
findParameters.FindOption = ESRI.ArcGIS.ADF.Web.FindOption.AllLayers;
findParameters.LayersAndFields = fieldsDictionary;
findParameters.FindString = "Arizona";
findParameters.MaxRecords = 10;
findParameters.ReturnADFGeometries = true;
findParameters.UseSqlContains = true;
System.Data.DataTable[] queryResultsDataTableArray = queryFunctionality.Find
(null, findParameters);
}
[VB.NET]
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)
System.Collections.Generic.Dictionary<Object, String = ""() >
fieldsDictionary = New System.Collections.Generic.Dictionary<Object, String = ""()>()
For Each layerID As String In layerIDs
Dim fieldsArray As String() = queryFunctionality.GetFields(Nothing, layerID)
fieldsDictionary.Add(layerID, fieldsArray)
Next layerID
Dim findParameters As ESRI.ArcGIS.ADF.Web.FindParameters = New ESRI.ArcGIS.ADF.Web.FindParameters()
findParameters.FindOption = ESRI.ArcGIS.ADF.Web.FindOption.AllLayers
findParameters.LayersAndFields = fieldsDictionary
findParameters.FindString = "Arizona"
findParameters.MaxRecords = 10
findParameters.ReturnADFGeometries = True
findParameters.UseSqlContains = True
Dim queryResultsDataTableArray As System.Data.DataTable() = queryFunctionality.Find(Nothing, findParameters)
End If