让结果集中的记录高亮显示(通用版)(转载)

让结果集中的记录高亮显示(通用版)(转载)让结果集中的记录高亮显示(通用版)(转载)Code
让结果集中的记录高亮显示(通用版)
我在结果集中每条记录后都加了一个按钮,写明“定位”,点击后执行下列语句:不敢独享,大家有更好的方法可以提意见,共同学习
protected void gvComponent_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        
        
if (e.CommandName == "MyCommand")
        {
           
//---------------------------------------------------------------

            SelectFeaturesGroup(LayerNames, Colors, WhereText, count, Map1, GridView1);
//------------------------------------------------     
            for (int i = 0; i < pointlist.Count; i++)
            {
                
if (pointlist is ESRI.ArcGIS.ADF.Web.Geometry.Point)
                {
                    ESRI.ArcGIS.ADF.Web.Geometry.Point pt 
= (ESRI.ArcGIS.ADF.Web.Geometry.Point)pointlist;
                    agf.DrawEvent(pt.X, pt.Y, Map1);
                }
                
if (pointlist is ESRI.ArcGIS.ADF.Web.Geometry.Polyline)
                {
                    ESRI.ArcGIS.ADF.Web.Geometry.Polyline line 
= (ESRI.ArcGIS.ADF.Web.Geometry.Polyline)pointlist;
                    agf.DrawEvent(line, Map1);
                }
                
if (pointlist is ESRI.ArcGIS.ADF.Web.Geometry.Polygon)
                {
                    ESRI.ArcGIS.ADF.Web.Geometry.Polygon poly 
= (ESRI.ArcGIS.ADF.Web.Geometry.Polygon)pointlist;
                    agf.DrawEvent(poly, Map1);
                }
            }
/// <summary>
    
/// 多个图层部分或全部控件不同颜色显示
    
/// </summary>
    
/// <param name="layernames">图层名</param>
    
/// <param name="color">显示颜色</param>
    
/// <param name="wheretext">查询条件</param>
    
/// <param name="count">MapResource的count</param>
    
/// <param name="Map1">Map控件</param>
    
/// <param name="GridView1">将部分控件信息显示到GridView中</param>

public void SelectFeaturesGroup(string[] layernames, System.Drawing.Color[] color, String[] wheretext, int count, Map Map1, GridView GridView1)
    {

Clear(Map1);
        
int resource_index = count;

        
string[] targetlayername = layernames;

        System.Data.DataTable[] datatable 
= new DataTable[layernames.Length];

        ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mf 
= (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality)Map1.GetFunctionality(resource_index);
        MapFunctionality mf1 
= (MapFunctionality)Map1.GetFunctionality(resource_index);
        ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapDescription 
= mf1.MapDescription;
        ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisresource 
= mf.Resource;
        
bool supported = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));
        
if (supported)
        {
            ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qfunc;
            qfunc 
= (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisresource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);

            
string[] lids;
            
string[] lnames;
            qfunc.GetQueryableLayers(
nullout lids, out lnames);

            
//-------------------------------------------------
            int[] layer_index = new int[layernames.Length];



            
for (int i = 0; i < targetlayername.Length; i++)
            {
                
for (int j = 0; j < lnames.Length; j++)
                {
                    
// 找到符合要求的图层编号
                    if (lnames[j] == targetlayername)
                    {
                        layer_index 
= j;
                        
break;
                    }
                }
            }
            
//-------------------------------------------------

            ESRI.ArcGIS.ADF.Web.SpatialFilter[] spatialfilter 
= new ESRI.ArcGIS.ADF.Web.SpatialFilter[targetlayername.Length]; ;
            
for (int i = 0; i < targetlayername.Length; i++)
            {
                spatialfilter 
= new ESRI.ArcGIS.ADF.Web.SpatialFilter();
                spatialfilter.ReturnADFGeometries 
= false;
                spatialfilter.MaxRecords 
= 1000;
                
if (wheretext != "" || wheretext != string.Empty)
                {
                    spatialfilter.WhereClause 
= wheretext;
                }
            }
            
//**********************8888888
            ESRI.ArcGIS.ADF.Web.Geometry.Envelope[] extent = new ESRI.ArcGIS.ADF.Web.Geometry.Envelope[layernames.Length];
            DataTable dtextent 
= new DataTable();
            dtextent.Columns.Add(
"XMax"typeof(double));
            dtextent.Columns.Add(
"XMin"typeof(double));
            dtextent.Columns.Add(
"YMax"typeof(double));
            dtextent.Columns.Add(
"YMin"typeof(double));
            
//**************************8888888888

            
for (int m = 0; m < layernames.Length; m++)
            {
                datatable[m] 
= qfunc.Query(null, lids[layer_index[m]], spatialfilter[m]);

                
//if (layernames.Length == 1 && datatable[m].Rows.Count == 0)
                
//{
                
//    return;
                
//}

                
//***********************88888888888
                DataRow drextent = dtextent.NewRow();
                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer graphicslayer 
= (ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer)ESRI.ArcGIS.ADF.Web.UI.WebControls.Converter.ToGraphicsLayer(datatable[m]);


                extent[m] 
= graphicslayer.FullExtent;

                drextent[
"XMax"= extent[m].XMax;
                drextent[
"XMin"= extent[m].XMin;
                drextent[
"YMax"= extent[m].YMax;
                drextent[
"YMin"= extent[m].YMin;

                dtextent.Rows.Add(drextent);
                
//*************************8888888888
            }

            
//*****************888888888888888
            double[] xmax = new double[dtextent.Rows.Count];
            
double[] xmin = new double[dtextent.Rows.Count];
            
double[] ymax = new double[dtextent.Rows.Count];
            
double[] ymin = new double[dtextent.Rows.Count];
            
for (int i = 0; i < dtextent.Rows.Count; i++)
            {
                xmax 
= (double)dtextent.Rows[0];
                xmin 
= (double)dtextent.Rows[1];
                ymax 
= (double)dtextent.Rows[2];
                ymin 
= (double)dtextent.Rows[3];

            }
//BubbleSort()是一个给数组排序的方法

            BubbleSort(xmax);
            BubbleSort(xmin);
            BubbleSort(ymax);
            BubbleSort(ymin);
            ESRI.ArcGIS.ADF.Web.Geometry.Envelope extent1 
= new ESRI.ArcGIS.ADF.Web.Geometry.Envelope();
            
int iLayerCount = 0;
            
for (int k = 0; k < xmax.Length; k++)
            {
                
if (xmax[k].ToString() != "非数字")
                {
                    iLayerCount
=k;
                    
break;
                }
            }
                    extent1.XMax 
= xmax[iLayerCount];
                    extent1.XMin 
= xmin[iLayerCount];
                    extent1.YMax 
= ymax[iLayerCount];
                    extent1.YMin 
= ymin[iLayerCount];
                
            System.Web.HttpContext.Current.Session[
"extent"= extent1;
            
//******************88888888888888
        }
        ArrayList al 
= new ArrayList();
        ArrayList pointname 
= new ArrayList();
        ArrayList pointlist 
= new ArrayList();
        
for (int m = 0; m < layernames.Length; m++)
        {
            
if (datatable[m] != null)
            {
                
int intShape = -1;
                
foreach (System.Data.DataColumn col in datatable[m].Columns)
                {
                    
if (col.ColumnName == "SHAPE")
                    {
                        intShape 
= col.Ordinal;
                        
break;
                    }
                }

                
for (int i = 0; i < datatable[m].Rows.Count; i++)
                {
                    pointname.Add(datatable[m].Rows[
"name"].ToString());
                    
if (datatable[m].Rows.ItemArray[intShape] is ESRI.ArcGIS.ADF.Web.Geometry.Point)
                    {
                        ESRI.ArcGIS.ADF.Web.Geometry.Point point2 
= (ESRI.ArcGIS.ADF.Web.Geometry.Point)datatable[m].Rows.ItemArray[intShape];

                        ESRI.ArcGIS.ADF.Web.Geometry.Point ptt 
= (ESRI.ArcGIS.ADF.Web.Geometry.Point)point2;
                        al.Add(ptt);

                    }
                    
if (datatable[m].Rows.ItemArray[intShape] is ESRI.ArcGIS.ADF.Web.Geometry.Polyline)
                    {
                        ESRI.ArcGIS.ADF.Web.Geometry.Polyline line 
= (ESRI.ArcGIS.ADF.Web.Geometry.Polyline)datatable[m].Rows.ItemArray[intShape];

                        ESRI.ArcGIS.ADF.Web.Geometry.Polyline pline 
= (ESRI.ArcGIS.ADF.Web.Geometry.Polyline)line;
                        al.Add(pline);
                    }
                    
if (datatable[m].Rows.ItemArray[intShape] is ESRI.ArcGIS.ADF.Web.Geometry.Polygon)
                    {
                        ESRI.ArcGIS.ADF.Web.Geometry.Polygon gon 
= (ESRI.ArcGIS.ADF.Web.Geometry.Polygon)datatable[m].Rows.ItemArray[intShape];

                        ESRI.ArcGIS.ADF.Web.Geometry.Polygon pgon 
= (ESRI.ArcGIS.ADF.Web.Geometry.Polygon)gon;
                        al.Add(pgon);
                    }
                }

            }

        }
        pointlist.Add(al);
        pointlist.Add(pointname);
        System.Web.HttpContext.Current.Session[
"SelectData"= pointlist;


        
//多层数据合并显示=================================
        DataTable dt2 = new DataTable();
        dt2.Columns.Add(
"OBJECTID"typeof(Int32));
        dt2.Columns.Add(
"name"typeof(string));
        dt2.Columns.Add(
"id_i"typeof(Int32));
        
for (int i = 0; i < layernames.Length; i++)
        {
            
for (int j = 0; j < datatable.Rows.Count; j++)
            {
                DataRow row 
= dt2.NewRow();
                row[
"OBJECTID"= datatable.Rows[j]["OBJECTID"];
                row[
"name"= datatable.Rows[j]["name"];
                dt2.Rows.Add(row);
            }
        }

        
for (int i = 0; i < dt2.Rows.Count; i++)
        {
            dt2.Rows[
"id_i"= i + 1;
        }
        GridView1.DataSource 
= dt2;
        GridView1.DataBind();

}

            Map1.Zoom(
100.0);
        }
 

 

原文地址:http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=22357&extra=page%3D3%26amp%3Bfilter%3Dtype%26amp%3Btypeid%3D6

版权说明

  如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
  作      者:温景良
  文章出处:http://wenjl520.cnblogs.com/  或  http://www.cnblogs.com/

posted @ 2009-02-25 14:04 温景良(Jason) Views(418) Comments(0) Edit 收藏
 

公告

 
 
本文转自我的程序人生博客园博客,原文链接:http://www.cnblogs.com/wenjl520/archive/2009/02/25/1397892.html,如需转载请自行联系原作者
 
 
上一篇:linux Centos 服务器之间文件共享挂载


下一篇:Problem About Salesforce SOAP API 32.0 In .Net Project