thank you vakant for your help..i worked with this code before you posted and it worked pretty well
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{
IMapFunctionality mf =
Map1.GetFunctionality("Redlands") as IMapFunctionality;
IGISResource gisresource = mf.Resource;
string targetLayername = "Parcels";
// Create the query functionality
IQueryFunctionality qfunc =
gisresource.CreateFunctionality(typeof(IQueryFunctionality), null)
as IQueryFunctionality;
string[] lids;
string[] lnames;
qfunc.GetQueryableLayers(null, out lids, out lnames);
int layer_index = 0;
for (int i = 0; i < lnames.Length; i++)
{
if (lnames.ToLower() == targetLayername.ToLower())
{
layer_index = i;
break;
}
}
// Create the spatial filter for the query
ESRI.ArcGIS.ADF.Web.SpatialFilter spatialfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
spatialfilter.ReturnADFGeometries = true;
spatialfilter.MaxRecords = 1000;
spatialfilter.WhereClause = "OBJECTID= " + GridView2.SelectedRow.Cells[1].Text;
spatialfilter.Geometry = Page.Session["Envelope"] as Envelope;
String[] flds = qfunc.GetFields(null, lids[layer_index]);
ESRI.ArcGIS.ADF.StringCollection scoll =
new ESRI.ArcGIS.ADF.StringCollection(flds);
spatialfilter.SubFields = scoll;
DataTable dt;
dt = qfunc.Query(null, lids[layer_index], spatialfilter);
// *** Step 7.d.: Convert the data table returned from the query
// *** and define symbology.
GraphicsLayer resultsGraphicsLayer;
resultsGraphicsLayer = ESRI.ArcGIS.ADF.Web.Converter.ToGraphicsLayer(dt, System.Drawing.Color.Red, System.Drawing.Color.Purple);
Map1.Extent = resultsGraphicsLayer.FullExtent;
// Apply a layer format to specify:
// * how selected features appear
// * field aliases
// * visible fields
// * primary display field
// * attribute formatting
// Retrieve the layer format for the active layer.
ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerFormat layerFormat =
ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerFormat.FromMapResourceManager(
Map1.MapResourceManagerInstance, mf.Resource.Name, lids[layer_index]);
// *** Step 7.e.: Apply the layer format of the active layer
// *** to the feature graphics layer.
layerFormat.Apply(resultsGraphicsLayer, true);
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality graphicsFunctionality;
graphicsFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)Map1.GetFunctionality("Selection");
// If RenderOnClient is true, the Web-tier graphics layer will be rendered on the client using the
// Web ADF JavaScript Library (GraphicFeatureGroup and GraphicFeatures).
// The default and highlight renderer defined as part of the active layer's layer format will be used during
// mouse over events on graphic features. Field and attribute display styles will be used to define the format of
// map tip (callout) content. If false, it will be rendered as a map image in the Web-tier using GDI+ and
// consolidated with other resource map images in the browser. Only layer format's default renderer will be used
// to render features - map tips will not be generated and the highlight renderer will not be used.
resultsGraphicsLayer.RenderOnClient = false;
if (resultsGraphicsLayer.RenderOnClient)
{
// Use ADF JavaScript to change active tool in toolbar and map control on client.
// This is optional.
// The mouse mode is set to Pan after Web-tier graphics are rendered on the client.
// This enables you to interact with map tips on graphic features without erroneously defining a new selection.
// NOTE: You need to activate the select tool to make another selection.
string jsToolbarItemDeactivate = @"
var toolbar = Toolbars['{0}'];
var currentToolField = $get(toolbar.currentToolField);
currentToolField.value = '';
toolbar.selectTool();
toolbar.refreshGroup();
$find('{1}').set_mouseMode(ESRI.ADF.UI.MouseMode.Pan);";
Toolbar adfToolbar = (Toolbar)Map1.Page.FindControl("Toolbar1");
adfToolbar.CurrentTool = string.Empty;
Map1.CurrentToolItem = null;
jsToolbarItemDeactivate = string.Format(jsToolbarItemDeactivate,
adfToolbar.ClientID, Map1.ClientID);
ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult deactivateToolbarItemsCallbackResult =
ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript(jsToolbarItemDeactivate);
Map1.CallbackResults.Add(deactivateToolbarItemsCallbackResult);
// Remove the current graphics feature group associated with the last selection. This will guarantee that the
// new graphics, attributes, and behaviors will be used. As a result, only one graphic feature group will reside
// in the client to represent the selection set.
if (graphicsFunctionality.GraphicsDataSet.Tables.Count > 0)
{
ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer oldFeatureGraphicsLayer =
(ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer)graphicsFunctionality.GraphicsDataSet.Tables[0];
// Use the Map.GetGraphicsLayerClientID to get the id of the respective graphic feature group that represents
// the Web-tier graphics layer.
string removeGraphicsClientScript = string.Format(@"
var glayer = $find('{0}');
var map = $find('{1}');
map.removeGraphic(glayer);
glayer.dispose();",
Map1.GetGraphicsLayerClientID(oldFeatureGraphicsLayer),
Map1.ClientID);
ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult cr =
ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript(removeGraphicsClientScript);
Map1.CallbackResults.Add(cr);
}
}
// Clear all contents of the graphic map functionality dataset
graphicsFunctionality.GraphicsDataSet.Tables.Clear();
// *** Step 7.g.: Add the selection graphics layer to the resource
graphicsFunctionality.GraphicsDataSet.Tables.Add(dt);
// Set the transparency of the selection graphics resource map resource item
ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem selectionMapResourceItem =
Map1.MapResourceManagerInstance.ResourceItems.Find(graphicsFunctionality.Resource.Name);
selectionMapResourceItem.DisplaySettings.Transparency = 50;
// *** Step 7.h.: Refresh the map resource
Map1.RefreshResource(graphicsFunctionality.Resource.Name);
Toc adfToc = Map1.Page.FindControl("Toc1") as Toc;
adfToc.Refresh();
}
}