Execute Custom Queries And Highlight Results

By Sasa Ivetic, GIS Software Developer, Manitoba, Canada

Orange ArrowDownload the script.

Code Summary 

Query Builder is a custom web control which allows the user to build a query and verify/execute it. The web control lists all of the layers that are available on the primary map resource. When a user selects a layer, the query automatically populates the list of columns (fields) for the layer. The user can then either manually type out the query, or double click on any of the columns and enter a value for it. The query has a standard SQL query syntax (i.e. ID=1234 AND Status=’Ready’). The user has the option of validating the query, or executing it. Validating will test for any errors in the query. Executing will run the query and highlight the results.

The web control allows for certain options to be set by the developer. The important options to set are the MapBuddyId and GraphicsLayerName, the rest are optional. It also allows for highlighting properties to be set, and the maximum number of results to be set.

Usage is kept relatively simple:
1 – Add the QueryBuilder.ascx file to your project
2 – Register the control in your ASPX file:

3 – Insert the QueryBuilder control into the ASPX File (< and > are removed from the following line):
qb:QueryBuilder ID=”QueryBuilder1″ runat=”server” MapBuddyId=”Map1″ GraphicsLayerName=”Graphics”
HighlightColor=”Aqua” MaxRecords=1000 PointMarkerSize=7 PointMarkerType=”Star” PolyBoundaryColor=”black”
PolyBoundaryTransparency=35 PolyFillType=”FDiagonal” PolyTransparency=25

One warning about the control. Executing complex queries, or queries which return a large number of results, especially on fields which are not indexed, may take a long time.

Advertisements

One Response to Execute Custom Queries And Highlight Results

  1. Mark Nguyen says:

    I am using VStudio2005. ArcGIS server 9.3 .NET ADF, my website using VB. I try your code and got this error message “this.Page ‘this.Page’ threw an exception of type ‘System.ArgumentNullException’ System.Web.UI.Page {System.ArgumentNullException}” on line 62 (QueryBuilder.ascx.cs)

    Line 61: mMap = this.Page.FindControl(mMapBuddyId) as Map;
    Line 62: mResManager = this.Page.FindControl(mMap.MapResourceManager) as MapResourceManager;

    I inserted the following lines of code to default.aspx
    1)

    2) also inserted querybuilder control in step3 (qb:QueryBuild ID=”QueryBuilder1″……)

    Could you let me know what wrong?
    Thanks,
    Mark

%d bloggers like this: