⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queryselect.cs

📁 C#开发的ArcGIS Server9.2地图查询控件
💻 CS
字号:
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Web;
using System.Web.UI;
using ESRI.ArcGIS.ADF.Tasks;
using ESRI.ArcGIS.ADF.Web.Display.Graphics;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;

namespace QuerySelectTaskCS
{
    /// <summary>
    /// An extension of the standard QueryAttributesTask. All features found are
    /// immediately selected on the map and in task results.
    /// </summary>
    /// <remarks>From ESRI ArcGIS Server Developer Blog, 2007</remarks>
    [ToolboxData("<{0}:QuerySelectTaskCS runat=\"server\" Width=\"200px\" Transparency=\"35\""
            + "BackColor=\"White\" TitleBarColor=\"WhiteSmoke\" TitleBarSeparatorLine=\"False\""
            + "TitleBarHeight=\"20px\" BorderColor=\"LightSteelBlue\" BorderStyle=\"Outset\""
            + "BorderWidth=\"1px\" Font-Names=\"Verdana\" Font-Size=\"8pt\" ForeColor=\"Black\">"
            + "</{0}:QuerySelectTaskCS>")]
    public class QuerySelectTaskCS: QueryAttributesTask
    {
        /// <summary>
        /// Handles selection of features. Override version just modifies the Results
        /// so that each feature found is set to selected.
        /// </summary>
        public override void ExecuteTask()
        {
            // Allow the QueryAttributesTask to create the results
            base.ExecuteTask();

            // We'll modify the Results next

            // Make sure features were found (if not, Results is SimpleTaskResult)
            if (Results is DataSet)
            {
                DataSet resultsDS = (DataSet)Results;

                // If any errors found during query, DS name will have "Error" in name
                if (resultsDS.DataSetName.IndexOf("Error") > 0)
                {
                    return;
                }

                // Next we can get the table of results

                // Get the one table in the QueryAttributesTask result
                DataTable resultsTable = resultsDS.Tables[0];

                // Make sure no problems creating a GraphicsLayer from the results
                if (resultsTable == null || !(resultsTable is GraphicsLayer))
                    return;
                // Now we can modify the table results
                GraphicsLayer graphicsLayer = (GraphicsLayer)resultsTable;

                // Get the column that holds the selection attribute
                DataColumn selectedCol = graphicsLayer.IsSelectedColumn;

                // Set each feature to selected
                foreach (DataRow row in graphicsLayer.Rows)
                {
                    row[selectedCol] = true;
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -