Welcome to ESRI Blogs

Displaying task results in a table

In this post, Tom Brenneman of ESRI Professional Services presents a Web control he developed for displaying task results in a table.

The standard Web ADF controls render task results with a tree view. This is allows multiple results as well as a variety of result types to be displayed in a uniform way. However some applications require that task results be displayed in a table without having to navigate the tree structure of the standard task results. There is an existing sample that illustrates how this can be done by working with custom tasks or application logic that dynamically updates an ASP.NET GridView control.

The custom control I've provided in this post is a little different in that it works with both standard tasks and custom tasks. Using this GridResults control, you can display the results of a task in a grid by simply adding the GridResults as a Task Result Container of the task. The table generated by the GridResults control also includes rows with buttons and check boxes to enable Pan, Zoom, and Select for each feature. This is what the GridResults control looks like in a web application:

GridResults control in a Web application 

As you can see in the example there are also links at the top to you can Select, Unselect, and Zoom to all of the features in the table. By clicking on the column headers you can sort data in the table. What you can’t see in the example above is that this control also supports ASP.NET themes, so you have complete control over the colors, fonts, and text sizes used by the control. Implementing themes for the control is discussed in more detail at the end of this post.

If you are using the Web Mapping Application template, there are slightly different ways to configure the grid than if you are using it in a standard web page. Below are instructions for each approach.

Using the GridResults control in a Web Mapping Application template application

  1. Install the GridResults web control.
  2. Using Visual Studio, create a new website using the Web Mapping Application template.
  3. Right-click anywhere on the Toolbox and click Choose Items...
  4. Click Browse and Navigate to gridResults.dll (Default location is C:\Program Files\ESRI\ArcGIS GridResults Control).
  5. Click OK to dismiss the Choose Toolbox Items dialog.
  6. Open the Source view for Default.aspx.
  7. Find the Results floating panel at about line 98. Highlight this block and copy it, then paste it immediately below. We are doing this with the Source view so you can be sure that the location you paste the floating panel is still in the left panel div with the rest of the floating panels. You also may want to keep the Results panel and standard task results container "TaskResults1" for tools such as Identify.
  8. Change the Title property of the new floating panel to "Table Results".
  9. Delete the entire TaskResults tag (TaskResults2) from the new Table Results panel.
  10. Drag gridResults from the Toolbox into the Table Results floating panel (Where the taskResults control used to exist). Your markup should look like the following.

    <esri:FloatingPanel ID="FloatingPanel1" runat="server"
    BackColor="White" BorderColor="White" BorderStyle="Solid"
    BorderWidth="1px" Font-Names="Verdana" Font-Size="8pt"
    ForeColor="Black" Height="150px" Style="position:relative; margin
    bottom:0px;" Draggable="False" Title="Table Results"
    TitleBarColor="White" TitleBarHeight="20px"
    TitleBarSeparatorLine="True" Transparency="0" Width="100%"
    HeightResizable="True" Font-Bold="True" CloseButton="False"
    TitleBarForeColor="DarkGray" Expanded="False"
    WidthResizable="False" ShowDockButton="True"
    ShowDockedContextMenu="True">
    <esri_samples:gridResults ID="GridResults1" runat="server"
    Height="200px" Style="position: absolute; overflow: auto;"
    Visible="True" Width="400px" />
    </esri:FloatingPanel>
  11. To make the grid display with scroll bars in the floating panel, we need to adjust the style attribute of the control. Change the style attribute to the following.

    Style="position:absolute; height:100%; width:100%; overflow:auto; left:0px; top:0px;"
  12. Switch to design view.
  13. Right-click on GridResults1 and click Properties.
  14. Set the Map property of the GridResults1 to the name of your map (Map1).
  15. Use the MapResourceManager to add a map resource to the application.
  16. Add tasks (such as QueryAttributesTask) to the task manager and configure their properties.
  17. Click the Smart Tag on your task(s) and click Choose Task Results container.
  18. Click Add and set the Name of the Buddy Control to GridResults1. If you use the standard TaskResults control with your tasks as well, make sure the standard TaskResults is the last one in the list.
  19. Click OK to the BuddyControl Collection Editor and run the application.
  20. When you execute the task, the floating panel will update with a table containing the results.

Using the GridResults control without a floating panel

Use the instructions below if you have created a web application without the Web Mapping Application template. In this case, you will set the style properties appropriately for your application.

  1. Open your web application in Visual Studio.
  2. Do steps 3-5 in the instructions from the previous section.
  3. Add the GridResults control to your page.
  4. Set the Map and other properties of the GridResults to display appropriately in your application. In the sample I use the following property settings.
    <esri_samples:gridResults ID="GridResults1" runat="server" Height="290px" Visible="True" Width="780px" Map="Map1" Style="position:absolute; overflow:auto; z-index: 500; left: 20px; top: 450px; vertical-align:top;" MinWidthOfZoom="0.001" />
  5. Do steps 15-20 in the instructions from the previous section.

Common properties of the GridResults control to modify

There are two additional properties that you may want to change specifically for your application: MinWidthOfZoom and ZoomExtentExpansionPercentage.

  • MinWidthOfZoom – this is the minimum width (or height actually) in map units of the extent rectangle that will be zoomed to. This is particularly useful if the result set is a single point or a very small feature. In this case you could set the minimum extent that the map will zoom to. If you are working with geographic data you may want to make this significantly smaller than the default of 10.
  • ZoomExtentExpansionPercent – this is the expansion percentage around the extent of the result set for the map to zoom to. This is useful for defining a margin around the extent of features returned in a result set.

Controlling the appearance of the results control with skins

The GridResults control is actually a Panel control containing a Label control (the resulting table name), Hyperlink controls (The zoom to all button, pan to all button, etc.), and a GridView control. The appearance of these controls honors the styleSheetTheme of your application. Using ASP.NET themes and skins you can control the look and feel of this control in your application. The following are the set of steps to enable themes and configure a skin for the table in the GridResults control. This example modifies the Blue_Bridge theme used by the Web Mapping Application template. If you aren’t using the Web Mapping Application template, you will have to create an appropriate theme for your application before walking through these steps.

  1. Enable style sheet themes by adding the following tag to your Web.config file.
    <pages styleSheetTheme="Blue_Bridge"/>
    If you are using the Web Mapping Application template you will want to leave the theme attribute as well, so your tag should look like this.
    <pages theme="Blue_Bridge" styleSheetTheme="Blue_Bridge"/>
  2. Open App_themes > Blue_Bridge > Default.skin.
  3. Add the appropriate tags to control the appearance of the Label, Hyperlink, and GridView controls contained within this control. Below is an example tag to make the symbology of the grid similar to the Blue_Bridge theme. You can copy and paste this into your skin file as an example.

    <asp:GridView runat="server" BackColor="White" BorderColor="#999999"
    BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
    <RowStyle BackColor="White" ForeColor="Black" />
    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
    <HeaderStyle BackColor="#79A8D1" Font-Bold="True" ForeColor="Black"/>
    <AlternatingRowStyle BackColor="#C0D4E4" />
    </asp:GridView>
  4. Save and run the application. When you execute the task, you should now see the results displayed in the table with a light blue header and a blue background for the alternating item (See the graphic at the top of this post for an example).

Try it out

Note: This control and its source code are provided for example purposes only and do not constitute a supported ESRI product. Please direct questions about this control to the Comments section of this blog. You may also post questions about using the ArcGIS Server Web ADF to the ESRI User Forums.

Update (February 26, 2008): I fixed a problem with the GridResults control where sorting didn't work right when there are multiple results. This problem is most evident when you use the GridResults control with the Identify tool. This new control is available on ArcScripts here: http://arcscripts.esri.com/details.asp?dbid=15452 .

Published Wednesday, October 24, 2007 1:58 PM by sterlingdq
Filed under: , ,

Comments

# re: Displaying task results in a table

Thanks Tom. This is great. I look forward to getting into the source code and also to combining this with some custom tasks I am working on.
Wednesday, October 24, 2007 3:46 PM by Randy

# re: Displaying task results in a table

nice work!
Wednesday, October 24, 2007 4:07 PM by jxn

# re: Displaying task results in a table

This looks great!  Thank you so much for your work on this.  Does it require SP3?  I received an error adding it to my toolbar and I suspect that may be why.  Also, I have a field marked as a hyperlink field in my map document.  Does this by chance support hyperlinked fields?

Thanks again!

Thursday, October 25, 2007 6:44 AM by cyndiee

# re: Displaying task results in a table

Yes, it does require SP3. I built it with those assemblies. You should be able to crack open the code and change all the references back to an earlier version and rebuild, but it is likely easier just to apply SP3.
Thursday, October 25, 2007 8:41 AM by Tom Brenneman

# re: Displaying task results in a table

This is very helpful.

I'm trying to build this on ArcGIS Server for Java.

I wanted to use Icefaces or Richfaces fot building a such complex Table.

Unfortanly, I can't get working the combination of Iceface/ArcGIS JSF resp. Richfaces/ArcGIS JSF library.

Has anybody a JAVA solution for this example?

Thanks,

Tom

Saturday, October 27, 2007 9:07 AM by TomLUX

# re: Displaying task results in a table

Where is GridResults_Display.js

I don't see it in the source?

Saturday, October 27, 2007 11:56 AM by vinnymac

# re: Displaying task results in a table

GridResults_Display.js was part of an earlier prototype that I was playing with for resizing the grid inside of a parent window. That approach was abandoned for the current approach which uses the style attribute of the control to enable the scaling and scrolling. I just forgot to take it out of the assembly attributes.
Saturday, October 27, 2007 9:08 PM by Tom Brenneman

# re: Displaying task results in a table

This is a nice tool. Can you tell me how we can link this up to the identify tool and use it for that as well?
Monday, October 29, 2007 10:01 AM by Chris

# re: Displaying task results in a table

Getting the GridResults to work with the Identify tool is a little trickier. The identify tool is a custom tool integrated into the Web Mapping Application template instead of a common task. So we need to modify its code a bit to work with the GridResults. First we need to modify its code file to use ITaskResultsContainer instead of TaskResults (the type for the standard tree-based task results).

In MapIdentify.vb or MapIdentify.cs

[VB]
Change:

Public Property ResultsDisplay() As TaskResults
Get
Return m_resultsDisplay
End Get
Set(ByVal value As TaskResults)
m_resultsDisplay = value
End Set
End Property
To:
Public Property ResultsDisplay() As ITaskResultsContainer
Get


Return m_resultsDisplay
End Get
Set(ByVal value As ITaskResultsContainer)
m_resultsDisplay = value
End Set
End Property

[C#]
Change:


public TaskResults ResultsDisplay
{
get { return m_resultsDisplay; }
set { m_resultsDisplay = value; }
}

To:


public ITaskResultsContainer ResultsDisplay
{
get { return m_resultsDisplay; }
set { m_resultsDisplay = value; }
}

Then at the the top of MapIdentify.vb or MapIdentify.cs:

[VB]
Change:

Private m_resultsDisplay As TaskResults = Nothing

To:

Private m_resultsDisplay As ITaskResultsContainer = Nothing

[C#]
Change:

private TaskResults m_resultsDisplay = null;

To:

private ITaskResultsContainer m_resultsDisplay = null;

We also need to point the identify class to the grid results on startup of the application. In the code-behind file for the default page, Default.aspx.vb or Default.aspx.cs, at about line 45:

[VB]
Change:

identify.ResultsDisplay = TaskResults1

To:

identify.ResultsDisplay = GridResults1

[C#]
Change:

identify.ResultsDisplay = TaskResults1;

To:

identify.ResultsDisplay = GridResults1;

Now, instead of putting the GridResults control into its own floating panel, replace TaskResults1 with GridResults1 in Default.aspx. Your markup should look like the following.


<esri:FloatingPanel ID="Results" runat="server" BackColor="White" BorderColor="White" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Height="150px" Style="position:relative; margin-bottom:0px;" Draggable="False" Title="Results" TitleBarColor="White" TitleBarHeight="20px" TitleBarSeparatorLine="True" Transparency="0" Width="100%" HeightResizable="True" Font-Bold="True" CloseButton="False" TitleBarForeColor="DarkGray" Expanded="False" WidthResizable="False" ShowDockButton="True" ShowDockedContextMenu="True">
<esri_samples:gridResults ID="GridResults1" runat="server" Height="200px" Style="position: absolute;overflow: auto; height:100%;width:100%; left:0px; top:0px;" Visible="True" Width="400px" Map="Map1" />
</esri:FloatingPanel>

Make sure you don’t change the name of the Results floating panel. The JavaScript for the Identify tool uses that name to open and close the panel. Next you need to modify that JavaScript to get the identify tool add the activity indicator to the correct control.
Change line 30 of display_mapidentify.js from

var fpBody = document.getElementById('Results_TaskResults1');

To

var fpBody = document.getElementById('Results_GridResults1');

Now your identify tool should use the GridResults control for its display. There are other dependencies in display_mapidentify.js on the name of the Results floating panel being named “Results”. So if you use a different name for your results floating panel, make sure to update those references as well.
Tuesday, October 30, 2007 3:02 PM by Tom Brenneman

# re: Displaying task results in a table

add in line 31 of display_mapidentify.js fpBody.innerHTML = ""; So the taskresult will refresh before a new identify. The identify is great. Thanks. But it works only for one resource... Can someone help me to make it working by more resources?
Wednesday, October 31, 2007 2:26 PM by Marco Wagemakers

# re: Displaying task results in a table

Scroll down in the floating panel you should see the other tables with the results from the other resources. The GridResults control adds the tables one after the other for each resource.
Thursday, November 01, 2007 5:44 AM by Tom Brenneman

# PrintTask

Any chance that anyone has modified Bryan Baker's PrintTask to work with this GridResults?
Friday, November 02, 2007 11:16 AM by Randy

# re: Displaying task results in a table

its a good tool. but, I could not see sourcecode writen by VB.
Thursday, November 08, 2007 5:57 PM by mika

# re: Displaying task results in a table

The "Hyperlinking in task results" blog from July shows an example (in C++ though I'm using VB) of how to override the ExecuteTask method to create a hyperlink in the results.  Can this be done with the GridResults Control also?

Friday, November 09, 2007 9:54 AM by cyndiee

# re: Displaying task results in a table

I receive this error message when trying to use the control "Unable to cast object of type 'esri_samples.gridResults' to type 'ESRI.ArcGIS.ADF.Web.UI.WebControls.TaskResults' ..............
Tuesday, November 13, 2007 8:14 AM by Gabriela Voicu

# re: Displaying task results in a table

mika, Sorry I only wrote the code in C#. The control will work with C# and VB.NET code but you can only modify the control using C#. Perhaps an online utility like the following would help. http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx
Tuesday, November 13, 2007 10:49 AM by Tom Brenneman

# re: Displaying task results in a table

cyndiee, Sorry but the control as it is now, will not display URL's as hyperlinks. The control would have to be modified to look for such string structures and add them to a hyperlink control. The existing framework of using template controls inside of the GridView is the framework that you would use to do this. Look at gridViewTemplates.cs for an example. The only difference is that when you construct the table in addResultsGridToPanel in gridResults.cs you would have to look at the actual column values instead of just the column names.
Tuesday, November 13, 2007 10:55 AM by Tom Brenneman

# re: Displaying task results in a table

Gabriela, You are getting this message because the GridResults control is not a type of TaskResults, it is an implementation of ITaskResultsContainer. TaskResults is a separate implementation of ITaskResultsContainer. The GridResults control does not extend the TaskResults like Rex and my post for the ZoomToResults control http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2007/08/28/Automatically-zooming-to-task-results.aspx. All of the standard tasks interact with the results control via the ITaskResultsContainer interface so both controls should work fine for all out-of-the-box ADF tasks controls. The identify tool is a little different in that it looks for a TaskResults type which is what lead to my response above on October 30th. Custom tasks may also be looking for a TaskResults type but these should be easy to change to ITaskResultsContainer.
Tuesday, November 13, 2007 11:06 AM by Tom Brenneman

# Identify on more that one layer

Tom, I followed your suggestions for identify: when in the results I have more than one layer I can see the results but column order doesn't work any more.
Wednesday, November 14, 2007 8:37 AM by Michael

# re: Displaying task results in a table

Michael,

Yes it looks like my code doesn't do sorting well when there are multiple table results.  Currently the control just tracks column and sort order but it should store a collection of objects with info for how each table should be sorted.  I'm not sure if I will have time to fix this but if you want to tackle it yourself RefreshGrid in gridresults.cs is a good place to start.  If I get a chance to fix it, I'll repost.

Wednesday, November 14, 2007 10:46 AM by tbrenneman@esri.com

# re: Displaying task results in a table

Cyndiee, I was able to add a hyperlink to the gridview if I added the link to the result dataset in the Overrides Execute Task of a custom task by using code similar to this below:
For Each DataRow As System.Data.DataRow In ds.Tables(0).Rows
strValue = DataRow("SampleColumn")
strLink = "<a target='_blank' href='http://www.google.com/search?q=" & strValue & "'>" & strValue & "</a>"
DataRow("SampleColumn") = strLink
Next
Thursday, November 15, 2007 8:07 PM by Randy

# re: Displaying task results in a table

I get an error "An unhandled exception has occurred: Object reference not set to an instance of an object" when I try to zoom or pan to any of the results in the table. Everything else works great. Any help would be great. Thanks
Monday, November 19, 2007 10:18 AM by Aaron Mielke

# re: Displaying task results in a table

This is a very nice tool. Now in my programming i've got a datatable, System.Data.DataTable datatable Can you tell me how we can link this up to the tool and use it for that as well?
Tuesday, November 20, 2007 2:06 AM by d y

# re: Displaying task results in a table

Is it possible to use this with the Common Select and Buffer Tool?
Tuesday, November 20, 2007 8:42 AM by Mike Bialousz

# re: Displaying task results in a table

I've got the same error as Aaron. Any ideas?
Tuesday, November 20, 2007 8:49 AM by Rocky

# DataTable to Gridresults

You need to add the table to a Dataset, then send the dataset to the DisplayResults function of ITaskResultsContainer. Here is the code:
     System.Data.DataTable datatable = qfunc.Query(null, lids[layer_index], queryfilter);
        DataSet ds = new DataSet();
        ITaskResultsContainer tskRC = GridResults1;

        if (datatable.Rows.Count > 0)
        {
            ds.Tables.Add(datatable);
            tskRC.DisplayResults(null, null, null, ds);
        }
        else
        {
            string heading = "No results found";
            string detail = "No results found";
            SimpleTaskResult str = new SimpleTaskResult(heading, detail);
            tskRC.DisplayResults(null, null, null, str);
        }
Tuesday, November 20, 2007 9:49 AM by Trent Tinker

# re: Displaying task results in a table

Is there a way to adjust what fields display in the gridresults?  I don't need them all.

Tuesday, November 20, 2007 12:20 PM by TToutant

# Limiting Fields

TToutant,

You can limit the number of fields a couple of ways. If you're not coding, use the mxd by going into the layer properties and choosing the fields that should be visible. Or, using .NET you can list the fields you'd like to return:

string list = "Field1,Field2,Field3";

       String[] flds = list.Split(',');

       ESRI.ArcGIS.ADF.StringCollection scoll = new ESRI.ArcGIS.ADF.StringCollection(flds);

       queryfilter.SubFields = scoll;

Tuesday, November 20, 2007 9:28 PM by Tink0519

# re: Displaying task results in a table

Is there a way to change the field names? I have a join in my mxd, so the field names are really long.

Tuesday, November 20, 2007 9:30 PM by Tink0519

# re: Displaying task results in a table

You need to add the table to a Dataset, then send the dataset to the DisplayResults function of ITaskResultsContainer. Here is the code:

    System.Data.DataTable datatable = qfunc.Query(null, lids[layer_index], queryfilter);

       DataSet ds = new DataSet();

       ITaskResultsContainer tskRC = GridResults1;

       if (datatable.Rows.Count > 0)

       {

           ds.Tables.Add(datatable);

           tskRC.DisplayResults(null, null, null, ds);

       }

       else

       {

           string heading = "No results found";

           string detail = "No results found";

           SimpleTaskResult str = new SimpleTaskResult(heading, detail);

           tskRC.DisplayResults(null, null, null, str);

       }

I'm trying to use this code to display the dataset to the gridviewResults but getting the following error.

No parameterless constructor defined for this object.

It works fine with the identify tool but doesn't work for the query.

Monday, November 26, 2007 11:19 AM by Nipa Parikh

# re: Displaying task results in a table

I like the menu. How did you get the dropdownlist instead of a static list? Thanks.
Tuesday, November 27, 2007 10:33 AM by Joe

# Displaying Select Tool Results in GridResults

Has anyone tried to combine this with the Custom Select Tool Task (http://arcscripts.esri.com/details.asp?dbid=15133)? I am trying to incorporate this now, but it doesn't like it when it get to the GetTaskResultsControls function.
Tuesday, November 27, 2007 12:28 PM by Mike

# re: Limiting Fields

Thanks Tink for the code about limiting the fields. The sample gives fields like "FID" and "ADF Geometry" that I have turned off, or don't have in an mxd. Where does the code snippet you provided go?
Tuesday, November 27, 2007 12:30 PM by Rocky

# re: Displaying task results in a table

Nipa,

Which object is your error refering to?

Tuesday, November 27, 2007 12:47 PM by Tink0519

# re: Limiting Fields

Rocky, The code snippet filters the field list return from the mxd. However, there are some fields that have to be returned, such as ADF Geometry. This field isn't in the MXD, but is used in the graphics layer within the ArcServer enviroment. To turn off those fields you need to make changes in the source code and recomplie the dll.

In the source code, open gridResults.cs and search for: dc.ColumnName != pGl.GraphicsIDColumn.ColumnName

Here you will find a list of the column names gridResults does not display such as "IS_SELECTED" and "SHAPE". Add any column names you do not want displayed to that if statement:

&& dc.ColumnName.ToUpper() != "ADF GEOMETRY"

Make sure you completely remove gridResults from your website before you try to use your newly compiled version, including removing the assembly reference in the web.config file. Hope this helps. -Trent, ROK Technologies

Wednesday, November 28, 2007 10:57 PM by Tink0519

# re: Displaying task results in a table

What I'm trying to do is run a Query by selecting parameters from the drop down list and then I would like to display that results in gridresults as a table. When I try to use the below code I'm getting error in DisplayResults line. No parameterless constructor defined for this object. I was able to get this to work for Identify tool but I like to do the same thing from the seperate query that I'm building. Any ideas? Nipa Parikh
Thursday, November 29, 2007 7:56 AM by Nipa Parikh

# re: Displaying task results in a table

I'm referring to the line that calls tskRC.DisplayResults(null, null, null, ds); It doesn't work and I can't see the results. Thanks for you help. Nipa Parikh
Thursday, November 29, 2007 8:15 AM by Nipa Parikh

# re: Displaying task results in a table

How can I see in gridresults domain values?
Friday, November 30, 2007 4:26 AM by Michael

# re: Limiting Fields

Tink0519 or Anyone, I downloaded the source code to my computer, now I am lost. I have created an application and added the gridResults web control to it I installed it than added to my toolbox and i am using it in my application to make Limiting Fields what do i do next what code i need to add to my application what steps i need to take do I need.

I am just trying to put the source code to my application so I can Limit the Fields, any help is a big help. Thank you.

Friday, November 30, 2007 9:01 AM by abakhtiyarov

# re: Displaying task results in a table

I got this application to work with Identify tool. When the user clicks on checkbox that feature displays on the map. I've a seperate button that should read the values of each checkbox. How do I do that? How can I read the gridresults checkbox values so see which one is turned on or off. Nipa Parikh
Friday, November 30, 2007 10:44 AM by Nipa.Parikh

# re: Displaying task results in a table

i want to start custimze the query task tool how can i do co
Tuesday, December 04, 2007 4:56 AM by Marwa

# re: Displaying task results in a table

I'd like to have the table launch in a new popup window - is this possible?

Tuesday, December 04, 2007 1:11 PM by drprune

# re: Displaying task results in a table

I've been trying to use the code to limit the fields shown in the grid results window. I can't seem to make it work. I have recompiled the dll and removed the grid results from my project including in the web.config file and it still doesn't work. I have specified the fields I don't want and they still come up. Any suggestions? Is there something I'm missing?
Wednesday, December 05, 2007 10:41 AM by Kirsten

# re: Displaying task results in a table

Tom, On postback the results of my gridView WebControl are lost whereas if the results are contained within a Task Results WebControl they persist across the postback. What am I missing?
Monday, December 10, 2007 7:19 AM by Aaron

# re: Displaying task results in a table

Tom, How can I access the data within the gridView after it has been generated? I am experienced working with the ASP.NET GridView, and would like to similarly parse information from the gridView results as part of a function I am writing. I also tried accessing ResultsNonGraphicsDataset to get direct access to the datatable; however, no datatable is returned.
Monday, December 10, 2007 11:24 AM by Aaron

# re: Displaying task results in a table

How would I go about adding the zoom and/or select tools to an ASP .Net Gridview? I need the flexibility of a standard Gridview (hyperlinks, template fields, nested gridviews) with the functionality of zooming to and/or selecting records like you have in this GridResults control. Any guidance would be appreciated.
Monday, December 10, 2007 12:39 PM by Mike

# re: Displaying task results in a table

Tom, would it be possible to add a linkbutton template to the gridresultstemplates.cs so that when that value was clicked it would zoom to that portion of the map?

Right now I've tried to make a linkbutton that will zoom to that portion of the map by modifying the GridViewButtonTemplate so that it works with a link button, but provides the functionality of the imagebutton. It still doesn't show up as a link though, and when I click on it nothing happens?

Is there some kind of event handler that isn't being specified? Does this make sense to you at all?

Wednesday, December 12, 2007 11:23 AM by BennyHusted

# re: Displaying task results in a table

Also, is there an easy way to make the selected column a radiobutton? I tried modifying the gridViewCheckBoxTemplate to use a radiobutton instead of a checkbox, but I can still select many of the results. I made sure the radiobuttons were using the same groupname too.

My goal here is to have only one result selected at any given moment.

Any ideas?

Wednesday, December 12, 2007 12:34 PM by BennyHusted

# re: Displaying task results in a table

How do you debug the dll so I can step through it?

Thursday, December 13, 2007 9:06 AM by bobtec

# re: Displaying task results in a table

I got the following error while running a coded ? tskRC.DisplayResults(Nothing, Nothing, Nothing, ds) Can someone help me? Exception occurred: The given key was not present in the dictionary
Friday, December 14, 2007 11:42 AM by Wayne

# re: Displaying task results in a table

Has anyone tried to combine this with the Custom Select Tool Task (http://arcscripts.esri.com/details.asp?dbid=15133)? I am trying to incorporate this now, but it doesn't like it when it get to the GetTaskResultsControls function.

Tuesday, December 18, 2007 7:51 AM by Nipa

# re: Displaying task results in a table

i too am trying to get the Custom Select Tool Task (http://arcscripts.esri.com/details.asp?dbid=15133) to work with gridResult. works fine in taskresult. i get a callback error but more specifically this seems to be the problem... "unable to cast object of type esri.sample.gridResult to type ESRI.ArcGIS.ADF.UI.WebControls.TaskResults" any help would be appreciated. thanks
Thursday, December 20, 2007 4:54 PM by Bryan

# re: Displaying task results in a table

Aaron and Rocky, Sorry I've been MIA from the blog for a while. Can you tell me how you are using the GridResults when you get the error: "An unhandled exception has occurred: Object reference not set to an instance of an object". What task have you buddied with the results container?
Friday, December 21, 2007 10:01 AM by Tom Brenneman

# re: Displaying task results in a table

Several of you have asked about using the GridResults with a tool on a toolbar (not a task). As has already been mentioned, you need to call DisplayResults on the ITaskResultsContainer interface and pass in a DataSet with the results you want displayed.  The trick is that you need to get a reference to the GridResults control from the tool.  To do this there is a FindControl function in the Utils static class.  Then after you've called DisplayResults you need to send the callbacks generated by the GridResults back to the client using the map control.  Below is some sample code.  In this code "ds" is the dataset with my results.

//Get the GridResults from the page

       esri_samples.gridResults gResults = esri_samples.Utils.FindControl<esri_samples.gridResults>(pMap.Page, "GridResults1");

       ITaskResultsContainer pTaskRes = gResults as ITaskResultsContainer;

       //Start the activity indicator to get the floating panel to expand.

       pTaskRes.StartTaskActivityIndicator(null, "");

       //Send the dataset to the DisplayResults method

       pTaskRes.DisplayResults(null, "", null, ds);

       //Add the callbacks of the GridResults to the callback of the map (referenced by pMap).

       //since all tools are processed through the map control, the map control

       //itself is in a callback and will take care of updating the grid for us.

       pMap.CallbackResults.CopyFrom(pTaskRes.CallbackResults);

       //Clear the callbacks in the grid so they don't get sent twice

       pTaskRes.CallbackResults.Clear();

I hope this helps.  Happy coding!

Friday, December 21, 2007 12:17 PM by Tom Brenneman

# re: Displaying task results in a table

The unhandled problem is fixed. (maybe) I did make some small changes in the source code and recompiled. Now the error is "Parser Error Message: ESRI.ArcGIS.ADF.Web.UI.WebControls.BuddyControlCollection must have items of type 'ESRI.ArcGIS.ADF.Web.UI.WebControls.BuddyControl'. 'esri.arcgis.adf.web.ui.webcontrols.buddycontrol' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'." Can anyone help? No idea where the HTML Generic control is coming from...
Wednesday, December 26, 2007 2:01 PM by Rocky

# re: Displaying task results in a table

Okay, changing the html tag from esri.arcgis.adf.web.ui.webcontrols.buddycontrol to esri:buddycontrol worked. But that was auto populated when I chose the control as the task container. Thanks for the code snip to limit the return fields, worked like a charm.
Thursday, December 27, 2007 6:42 AM by Rocky

# Display field alias names

Hi Tom. Your grid control helped me very much, because previously I was not able to fully localize task results for Georgian language. Now I just have one problem - I need use field alias names instead of real names. Have you any suggestions about it? Thanks.
Friday, December 28, 2007 4:07 AM by Anania

# re: Displaying task results in a table

I want to implement same technology in JAVA If anybody has Java so;ution for this scenerio, Please provide the same.

Thanks

Saturday, January 05, 2008 5:02 AM by aroranidh

# re: Displaying task results in a table

Okay...Bryan Baker retooled the Custom Select Tool Task to work with GridResults. Works great. Anybody know how to pass a Geoprocessing Task result to the GridResults. And\Or export the GridResults to CSV or excel with the code behind a button (export button). Everyone has been extremely helpful! Thanks! Bryan
Friday, January 11, 2008 2:19 PM by Bryan

# re: Displaying task results in a table

Tom, I had a quick question regarding the GridResults control. When I buddy up a QueryAttributesTask with GridResults1 (for example) the results are returned. However, if I pan or zoom I get the error that Aaron & Rocky from above got "An unhandled exception has occurred: Object reference not set to an instance of an object". But if I use the SearchAttributesTask the zoom and pan work great. FYI - I am on sp3. Any Ideas. Thanks! JB
Tuesday, January 15, 2008 8:21 AM by Jeff Bray

# Problem with the Scrollbar

Thank you, this control works great. But I have a little problem: When I use the scrollbar to scroll down in a big result and then change the selection or sort a table, then the scrolbar scrolls up and I need to find my former position. Again, thank you
Wednesday, January 16, 2008 7:35 AM by Andreas Roelovs

# re: Displaying task results in a table

FYI, who ever has been getting the zoom/pan errors with this control--one thing that worked for me: Make sure your shape field is not hidden in your MXD.
Thursday, January 17, 2008 12:46 PM by Evan

# re: Displaying task results in a table

Hi. This works very nice. Thanks. I have one problem: When i try zooming to a record in the result table, instead of zooming in to the selrcted record the map zooms out to full extent. Any ideas? Thanks, Michael.
Friday, January 18, 2008 12:33 AM by Michael

# re: Displaying task results in a table

Dim ds As New DataSet()

           Dim gResults As esri_samples.gridResults = esri_samples.Utils.FindControl(Of esri_samples.gridResults)(Map1.Page, "GridResults1")

           Dim pTaskRes As ITaskResultsContainer = TryCast(gResults, ITaskResultsContainer)

 If datatable.Rows.Count > 0 Then

               ds.Tables.Add(datatable)

               '    'Me.GridResults1.FindControl("GridView1")

               pTaskRes.DisplayResults(Nothing, "", Nothing, ds)

           Else

               Dim heading As String = "No results found"

               Dim detail As String = "No results found"

               Dim str As New SimpleTaskResult(heading, detail)

               pTaskRes.DisplayResults(Nothing, "", Nothing, str)

           End If

When I tried the above code I'm getting the following error.

No parameterless constructor defined for this object.

Any help is appreciated.

Thanks.

Tuesday, January 22, 2008 9:28 AM by Nipa Parikh

# re: Displaying task results in a table

I am also havign the same error "no parameterless constructor defined"..please let me know if I missed anything
Friday, January 25, 2008 3:25 AM by Surender

# re: Displaying task results in a table

Hi Nipa,

I was able rectify the issue of no parameterless query...  the grid view control takes input as graphic dataset and in your code you are sending the system.data.dataset..so it throws an error..

please check the code below which i am using it.. it does not throw any error.

Dim datatable As System.Data.DataTable = qfunc.Query(Nothing, lids(layer_index), spatialfilter)

                   Dim graphicslayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer = ESRI.ArcGIS.ADF.Web.Converter.ToGraphicsLayer(datatable, System.Drawing.Color.Yellow, System.Drawing.Color.Yellow)

                   Dim selresource As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource = Nothing

                   For Each gfunc In gfc

                       If gfunc.Resource.Name = "Selection" Then

                           selresource = CType(gfunc.Resource, ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)

                           selresource.Graphics.Tables.Clear()

                       End If

                   Next

                   If selresource Is Nothing Then

                       Return "Nothing"

                   End If

                   'selresource.Graphics.Tables.Add(graphicslayer)                    '''''''

                   Dim gds As New ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsDataSet

                   Dim gResults As esri_samples.gridResults = esri_samples.Utils.FindControl(Of esri_samples.gridResults)(m_page, "GridResults1")

                   Dim pTaskRes As ITaskResultsContainer = TryCast(gResults, ITaskResultsContainer)

                   If datatable.Rows.Count > 0 Then

                       'ds.Tables.Add(datatable)

                       gds.Tables.Add(graphicslayer)

                       pTaskRes.DisplayResults(Nothing, "", Nothing, gds)

                       selresource.Graphics = gds

                   Else

                       Dim heading As String = "No results found"

                       Dim detail As String = "No results found"

                       Dim str As New SimpleTaskResult(heading, detail)

                       pTaskRes.DisplayResults(Nothing, "", Nothing, str)

                       pTaskRes.Refresh()

                   End If

But I have a issue..after this the Grid results are not displayed.. the Results pnale does not refresh..can anyone help

Friday, January 25, 2008 6:02 AM by Surender rao k

# re: Displaying task results in a table

Dim gds As New DataSet Dim gResults As esri_samples.gridResults = esri_samples.Utils.FindControl(Of esri_samples.gridResults)(Map1.Page, "GridResults1") Dim pTaskRes As ITaskResultsContainer = TryCast(gResults, ITaskResultsContainer) If datatable.Rows.Count > 0 Then Dim layer As Display.Graphics.GraphicsLayer = ESRI.ArcGIS.ADF.Web.Converter.ToGraphicsLayer(datatable, System.Drawing.Color.Empty, System.Drawing.Color.Black) If Not (layer Is Nothing) Then gds.Tables.Add(layer) Else gds.Tables.Add(datatable) End If pTaskRes.StartTaskActivityIndicator(Nothing, "") pTaskRes.DisplayResults(Nothing, "", Nothing, gds) Map1.CallbackResults.CopyFrom(pTaskRes.CallbackResults) pTaskRes.CallbackResults.Clear() End If
Friday, January 25, 2008 11:38 AM by Nipa

# re: Displaying task results in a table

Hi Surender,

  Thanks for your code but I'm having the same issue of not displaying Gridresults.  Please let me know if you find any solution.

Thanks.

Nipa

Monday, January 28, 2008 4:35 AM by Nipa

# re: Displaying task results in a table

Hi Nipa, I got the solution for not displaying grid resutls... the reason for this is that you r not performing the callbacks after data is loaded to gridresults1. Please see the below code for callback which works for me.. ObjmapSelection -> is my map control name. If datatable.Rows.Count > 0 Then gds.Tables.Add(graphicslayer) pTaskRes.StartTaskActivityIndicator(Nothing, "") pTaskRes.DisplayResults(Nothing, "", Nothing, gds) objmapselection.CallbackResults.CopyFrom(pTaskRes.CallbackResults) Else Dim str As New SimpleTaskResult(heading, detail) pTaskRes.StartTaskActivityIndicator(Nothing, "") pTaskRes.DisplayResults(Nothing, "", Nothing, str) End If Return objmapselection.CallbackResults.ToString() Hope this solves your problem.. Regards, Surender
Monday, January 28, 2008 4:55 AM by Surender

# re: Displaying task results in a table

Hi Surender, Map1 is my map control name and I added Could you please more about "Return Map1.CallbackResults.ToString()" Where the returned string goes? I tried to put it into the function involved after clicking a button. But the gridresults is still not displayed. Thanks! Nipa
Monday, January 28, 2008 11:59 AM by Nipa

# re: Displaying task results in a table

Nipa, are you still trying to get the Custom Select Tool Task (http://arcscripts.esri.com/details.asp?dbid=15133) to output to the gridresults? Bryan Baker fixed it so you can now choose where the data is displayed (TaskResults or Gridresults) by selecting it in the BuddyControl. http://edndoc.esri.com/arcobjects/9.2/NET_Server_Doc/developer/ADF/control_taskresults.htm Anybody know how to export the gridresults to excel or csv?
Monday, January 28, 2008 8:27 PM by Bryan

# re: Displaying task results in a table

Hi Nipa, There two call back statements for refreshing the grid once the spatial query is completed (i.e the data is added to datatable..please make sure datatable.rows.count is greater than zero) the two call back statemetns are 1. pTaskRes.StartTaskActivityIndicator(Nothing, "") this will start the Indicator Gif in grid control. 2.pTaskRes.DisplayResults(Nothing, "", Nothing, gds)..this will add the data to grid control these two should be in this if loop If datatable.Rows.Count > 0 Then here.... else endif after if loop use objmapselection.CallbackResults.CopyFrom(pTaskRes.CallbackResults) pTaskRes.CallbackResults.Clear() Return objmapselection.CallbackResults.ToString() This should work..
Tuesday, January 29, 2008 6:09 AM by Surender rao k

# re: Displaying task results in a table

Surender, I did exactly same thing and the gridresults is still not displayed. Could you share more of your code? Thanks! Nipa
Tuesday, January 29, 2008 11:38 AM by Nipa

# re: Displaying task results in a table

Hi Nipa, Please find the code for Polygon Search and place the results to Grid view.. Note: My GridView control is in "TableResuls" Panel and Grid Control name is "GridRwesult1" Code below: Dim gResults As esri_samples.gridResults = esri_samples.Utils.FindControl(Of esri_samples.gridResults)(m_page, "GridResults1") Dim pTaskRes As ITaskResultsContainer = TryCast(gResults, ITaskResultsContainer) If eventArg = "polygon" Then Dim ims_map_points As Object = Session("ims_map_points") Dim ring As ESRI.ArcGIS.ADF.Web.Geometry.Ring = New ESRI.ArcGIS.ADF.Web.Geometry.Ring() Dim mappoly As ESRI.ArcGIS.ADF.Web.Geometry.Polygon = New ESRI.ArcGIS.ADF.Web.Geometry.Polygon() Dim rings As ESRI.ArcGIS.ADF.Web.Geometry.RingCollection = New ESRI.ArcGIS.ADF.Web.Geometry.RingCollection() Dim mf As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = Nothing Dim gisresource As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource = Nothing Dim qfunc As ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality = Nothing Dim graphicslayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer = Nothing Dim gds As New ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsDataSet Dim spatialfilter As ESRI.ArcGIS.ADF.Web.SpatialFilter = Nothing Dim datatable As System.Data.DataTable = Nothing Dim heading As String = "No results found" Dim detail As String = "No results found" Dim lids() As String = Nothing Dim lnames() As String = Nothing Dim mapResItemval As Integer Dim layer_index As Integer = 0 Dim layerCount As Integer ring.Points = ims_map_points rings.Add(ring) mappoly.Rings = rings For mapResItemval = 0 To objmapselection.MapResourceManagerInstance.ResourceItems.Count - 1 If objmapselection.MapResourceManagerInstance.ResourceItems(mapResItemval).Name = ConfigurationManager.AppSettings("MapResourceItemName") Then mf = CType(objmapselection.GetFunctionality(mapResItemval), _ ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality) End If Next ' end of for loop gisresource = mf.Resource qfunc = CType(gisresource.CreateFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), Nothing), ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality) qfunc.GetQueryableLayers(Nothing, lids, lnames) For layerCount = 0 To lnames.Length - 1 Step layerCount + 1 If lnames(layerCount) = HttpContext.Current.Session("ActiveLayerName") Then 'targetlayername Then layer_index = layerCount Exit For End If Next spatialfilter = New ESRI.ArcGIS.ADF.Web.SpatialFilter() spatialfilter.ReturnADFGeometries = True spatialfilter.MaxRecords = 500 spatialfilter.Geometry = mappoly spatialfilter.SearchOrder = SearchOrder.Spatial datatable = qfunc.Query(Nothing, lids(layer_index), spatialfilter) graphicslayer = ESRI.ArcGIS.ADF.Web.Converter.ToGraphicsLayer(datatable, Drawing.Color.Cyan, Drawing.Color.Cyan) // gds.DataSetName = [String].Format("{0} - {1} ({2})", "Selection", graphicslayer.TableName, datatable.Rows.Count) pTaskRes.CallbackResults.Clear() If datatable.Rows.Count > 0 Then gds.Tables.Add(graphicslayer) pTaskRes.StartTaskActivityIndicator(Nothing, "") pTaskRes.DisplayResults(Nothing, "", Nothing, gds) Else Dim str As New SimpleTaskResult(heading, detail) pTaskRes.StartTaskActivityIndicator(Nothing, "") pTaskRes.DisplayResults(Nothing, "", Nothing, str) End If gds.Clear() spatialfilter = Nothing qfunc = Nothing End If objmapselection.CallbackResults.CopyFrom(pTaskRes.CallbackResults) pTaskRes.CallbackResults.Clear() Return objmapselection.CallbackResults.ToString() Hope this will help to fix your errror Regards, Surender rao k
Wednesday, January 30, 2008 10:18 AM by Surender

# re: Displaying task results in a table

Hi All, I need to add a "Export" in the GridView similar to "Select ALL,"Zoom to All" and On click of "Export" Button I need to Export the Grid View Results to an Excel sheet. Please let me how to implement this... Regards, Surender rao k
Thursday, January 31, 2008 2:53 AM by Surender

# re: Displaying task results in a table

Hi Surender, Thanks for your code but I've pasted my function that I'm calling from a button pressed. I'm really confused and can definately use your help to figure out why the gridresults is not showing. Please give me some guidance. Thanks. CODE: Public Function SelectFeatures() Dim WhereClauseString As String = "" Dim EmulsionString As String = "" Dim sensorTypeString As String = "" Dim o As ListItem Dim resource_index As Integer = 2 'Index of resource in MapResourceManager Dim targetlayername = "Photo Footprints" Dim mf As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = CType(Map1.GetFunctionality(resource_index), ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality) Dim gisresource As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource = mf.Resource Dim supported As Boolean = gisresource.SupportsFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)) If supported Then Dim qfunc 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 lids() As Object = Nothing Dim lnames() As String = Nothing qfunc.GetQueryableLayers(Nothing, lids, lnames) Dim layer_index As Integer = 0 Dim i As Integer For i = 0 To lnames.Length - 1 If lnames(i) = targetlayername Then layer_index = i Exit For End If Next i Dim adfEnvelope As ESRI.ArcGIS.ADF.Web.Geometry.Envelope adfEnvelope = Map1.Extent Dim spatialfilter As New ESRI.ArcGIS.ADF.Web.SpatialFilter() spatialfilter.ReturnADFGeometries = True spatialfilter.Geometry = adfEnvelope spatialfilter.MaxRecords = 1000 WhereClauseString = "STATE=" & "'" & Me.state.SelectedValue & "' and (" WhereClauseString &= "year(exposedate) between " & Me.ExposeDateFrom.SelectedValue & " and " & Me.ExposeDateTo.SelectedValue & ")" For Each o In emulsion.Items If o.Selected = True Then EmulsionString &= "Emulsion=" & "'" & o.Value & "' OR " End If Next If EmulsionString.Length > 0 Then WhereClauseString &= " and (" & Left(EmulsionString, EmulsionString.Length - 4) & ")" End If For Each o In sensortype.Items If o.Selected = True Then sensorTypeString &= CommonFunctions.getCameraList(o.Value) End If Next If sensorTypeString.Length > 0 Then WhereClauseString &= " and (" & Left(sensorTypeString, sensorTypeString.Length - 4) & ")" End If 'for Debugging purpose only WhereClauseString = "STATE='FL' and (year(exposedate) between 2006 and 2006) and (Emulsion='11' OR Emulsion='1') and (sensortype='1' OR sensortype='2' OR sensortype='3' OR sensortype='4' OR sensortype='5' OR sensortype='6' OR sensortype='7' OR sensortype='8' OR sensortype='9' OR sensortype='10' OR sensortype='11' OR sensortype='12' OR sensortype='13' OR sensortype='14' OR sensortype='15' OR sensortype='16' OR sensortype='17' OR sensortype='18' OR sensortype='19' OR sensortype='20' OR sensortype='21' OR sensortype='22')" spatialfilter.WhereClause = WhereClauseString 'spatialfilter.WhereClause = "State='FL'" Dim flds As String() = qfunc.GetFields(Nothing, lids(layer_index)) Dim scoll As New ESRI.ArcGIS.ADF.StringCollection(flds) spatialfilter.SubFields = scoll Dim datatable As System.Data.DataTable = qfunc.Query(Nothing, lids(layer_index), spatialfilter) Dim gfc As IEnumerable = Map1.GetFunctionalities() Dim gResource As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource = Nothing Dim gfunc As IGISFunctionality For Each gfunc In gfc '***Exercise 5 Step 3.a: Get the GraphicsLayer Resource by name If gfunc.Resource.Name = "Selection" Then gResource = CType(gfunc.Resource, ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource) End If Next gfunc If gResource Is Nothing Then Exit Function End If Dim glayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer = Nothing Dim dt As System.Data.DataTable For Each dt In gResource.Graphics.Tables If TypeOf dt Is ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer Then glayer = CType(dt, ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer) Exit For End If Next dt If glayer Is Nothing Then '***Exercise 5 Step 3.b: Create a new ElementGraphicsLayer glayer = New ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer() '***Exercise 5 Step 3.c: Add the GraphicsLayer to the GraphicsDataSet gResource.Graphics.Tables.Add(glayer) End If glayer.Clear() Dim drs As DataRowCollection = datatable.Rows Dim shpind As Integer = -1 'Dim i As Integer For i = 0 To datatable.Columns.Count - 1 If datatable.Columns(i).DataType Is GetType(ESRI.ArcGIS.ADF.Web.Geometry.Geometry) Then shpind = i Exit For End If Next i Try Dim dr As DataRow For Each dr In drs Dim geom As ESRI.ArcGIS.ADF.Web.Geometry.Geometry = CType(dr(shpind), ESRI.ArcGIS.ADF.Web.Geometry.Geometry) '***Exercise 5 Step 3.d: Create a new GraphicElement Dim ge As New ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(geom, System.Drawing.Color.DarkRed) Dim pSimpleFill As New ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol pSimpleFill.BoundaryColor = Drawing.Color.DarkRed pSimpleFill.Transparency = 100 ge.Symbol = pSimpleFill '***Exercise 5 Step 3.e: Add the GraphicElement to GraphicsLayer glayer.Add(ge) Next dr Catch ice As InvalidCastException End Try If Map1.ImageBlendingMode = ImageBlendingMode.WebTier Then Map1.Refresh() Else If Map1.ImageBlendingMode = ImageBlendingMode.Browser Then '***Exercise 5 Step 3.f: Refresh the Graphics Resource Map1.RefreshResource(gResource.Name) End If End If 'Dim drow As DataRow If (Not datatable Is Nothing) Then 'For Each drow In drs ' drow("NGS_PHOTOS.NGS_PHOTOS.FLORIDA_FOOTPRINTS.State") = "" & drow("NGS_PHOTOS.NGS_PHOTOS.FLORIDA_FOOTPRINTS.State") & "" 'Next 'GridView1.DataSource = datatable 'Session("datatable") = datatable 'GridView1.DataBind() For Each c As DataColumn In datatable.Columns c.ColumnName = c.ColumnName.Replace("NGS_PHOTOS.NGS_PHOTOS.FLORIDA_FOOTPRINTS.", "") Next Session("datatable") = "" Me.RadGrid1.DataSource = datatable Session("datatable") = datatable ' Me.RadGrid1.DataBind() End If 'This part is not working to copy the resultsset to the gridresults. 'the gridresults is not displayed Dim gds As New DataSet Dim gResults As esri_samples.gridResults = esri_samples.Utils.FindControl(Of esri_samples.gridResults)(Map1.Page, "GridResults1") Dim pTaskRes As ITaskResultsContainer = TryCast(gResults, ITaskResultsContainer) If datatable.Rows.Count > 0 Then Dim layer = ESRI.ArcGIS.ADF.Web.Converter.ToGraphicsLayer(datatable, System.Drawing.Color.Empty, System.Drawing.Color.Black) If Not (layer Is Nothing) Then gds.Tables.Add(layer) pTaskRes.StartTaskActivityIndicator(Nothing, "") pTaskRes.DisplayResults(Nothing, "", Nothing, gds) Else gds.Tables.Add(datatable) End If End If Map1.CallbackResults.CopyFrom(pTaskRes.CallbackResults) pTaskRes.CallbackResults.Clear() End If Return Map1.CallbackResults.ToString() End Function
Friday, February 01, 2008 10:38 AM by Nipa Parikh

# re: Displaying task results in a table

Hi Nipa, Can you please send the complete code in Zip format to my mail ID (surender_karanam@hotmail.com).. I will fix the error and send to you back. According to me there should some small issue which should get fixed quickly. I was also able to solve the Export to Excel from Grid last day. Regards, Surender rao k
Monday, February 04, 2008 1:09 AM by Sureder

# re: Displaying task results in a table

Hi Surender,

  I was looking at your code and trying to compare with mine and I see two differences.

I'm using dropdown list to build my query and hit a submit button that actually calls the function and then display the result in the grid results.

Can you please tell me how should I have my button_click event display the gridresults.

Map1.CallbackResults.ToString() has the whole gridresults content but just not displaying it.

I can really use some help because I'm stuck and can't move forward.

Nipa

Monday, February 04, 2008 8:42 AM by Nipa

# re: Displaying task results in a table

Nipa, I am not able to idenify what exactly the error you are getting..Can you send your code so that I can fix it an send you back.. my email id is surender_karanam@hotmail.com (+4407809562342) Regards, Surender rao k
Monday, February 04, 2008 8:59 AM by Surender

# re: Displaying task results in a table

Hi Powell, As requested please find the code for Export to Excel. I have added one more Case called "gridiewExport" in the GridTool Code in c#... this works Great for me. Code below -----------------------------------------
case "gridViewExport":
//This is the Export Link above the Grid Resutls and
//below code exports the gridview results to Excel file
GridView gv = (GridView)Page.Session["gview"];
// this for loop is to hide the Zoom,Pan, Report, Check box fields
// while exporting the excel sheet
foreach (TemplateField dColumn in gv.Columns)
{
if (dColumn.HeaderText == "Selected")
{ dColumn.Visible = false;
break;
}
dColumn.Visible = false;
}
string strFileName = String.Empty, strFilePath = String.Empty;

strFileName = (HttpContext.Current.Session["HttpSessionID"] + "Report.xls");
strFilePath = HttpContext.Current.Server.MapPath("./ExportData/") + strFileName;
if (File.Exists(strFilePath))
{
File.Delete(strFilePath);
}
System.IO.StringWriter oStringWriter = new StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
StreamWriter objStreamWriter;
////string strStyle = @" .text { mso-number-format:\@; }";
objStreamWriter = File.AppendText(strFilePath);
//Utils.ClearControls();
// Utils.PrepareGridViewForExport(gv);
gv.RenderControl(oHtmlTextWriter);
//objStreamWriter.WriteLine(strStyle);
objStreamWriter.WriteLine(oStringWriter.ToString());
objStreamWriter.Close();

string strScript = "window.open('./ExportData/" + strFileName + "','Export');";
CallbackResults.Add(new CallbackResult(Parent, "javascript", strScript));
break;
Tuesday, February 05, 2008 3:54 AM by Surender

# re: Displaying task results in a table

It works fine but in the data table , I still get 3 first columns: GeometryElement, FID, Shape, that I do not need to be shown.

I use ArcMap to make these fields invisible but still in the application, they are still there.

Could you please tell me how to limit the fields and do not have these 3 fields displaying in the table?

I try to read all the comments here but could not make it.

Thanks for your help !

Thursday, February 07, 2008 4:44 AM by LParson

# re: Displaying task results in a table

Hi I have trouble using this control. To me it displays result in gridview but when I click zoomto selected feature it zooms to full extent. Anybody knows why it is happening.
Monday, February 11, 2008 6:59 PM by Satya

# re: Displaying task results in a table

I was able to get this working all the way through. However my problem is with the selection portion. Whenever I try to select any results, it gives me the "An unhandled exception has occured: There was an error in the callback." I do not have Zoom to Results anywhere in the app and only have the GridResults as the ending task container. Any help?
Tuesday, February 12, 2008 5:24 PM by Fernando

# re: Displaying task results in a table

Hallom LParson, look in the gridResults.cs file, line 590-593 look like this: if (dc.ColumnName != pGl.GraphicsIDColumn.ColumnName && dc.ColumnName.ToUpper() != "IS_SELECTED" && dc.ColumnName.ToUpper() != "SHAPE" && dc.ColumnName != c_sTableIdColumnName) here the colums "IS_SELECTED" and "SHAPE" are set to unvisible. Add your columns there to hide them. Does nobody knows how to solve the scroll problem? Bye
Tuesday, February 12, 2008 11:14 PM by Andreas Roelovs