Common_TaskResults_VBNet\TaskResultsWebSite\DataTableResult.aspx.vb
' Copyright 2011 ESRI ' ' All rights reserved under the copyright laws of the United States ' and applicable international laws, treaties, and conventions. ' ' You may freely redistribute and use this sample code, with or ' without modification, provided you include the original copyright ' notice and use restrictions. ' ' See the use restrictions. ' Imports Microsoft.VisualBasic Imports System Public Partial Class DataTableResult Inherits System.Web.UI.Page Protected Sub Toolbar1_CommandClick(ByVal sender As Object, ByVal toolbarCommandClickEventArgs As ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolbarCommandClickEventArgs) ' Check to make sure our custom command was clicked. This is not necessary in this case since there ' is only one item on the toolbar, but is included here for demonstration. Select Case toolbarCommandClickEventArgs.CommandName Case ("ExecuteQuery") ' Get the map resource item to be queried and make sure the underlying resource is initialized Dim mapResourceItem As ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem = MapResourceManager1.ResourceItems.Find("MapResourceItem0") If (Not mapResourceItem.Resource.Initialized) Then mapResourceItem.InitializeResource() End If ' Create a query functionality to use in executing the query Dim commonQueryFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality = TryCast(mapResourceItem.Resource.CreateFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), "addDataResultQueryFunctionality"), ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality) ' Create a query filter and specify a generic where clause. Also specify that geometries not be ' returned to improve performance. Dim adfQueryFilter As ESRI.ArcGIS.ADF.Web.QueryFilter = New ESRI.ArcGIS.ADF.Web.QueryFilter() adfQueryFilter.WhereClause = "OBJECTID < 100" adfQueryFilter.ReturnADFGeometries = False ' Execute the query Dim resultsTable As System.Data.DataTable = commonQueryFunctionality.Query(Nothing, "0", adfQueryFilter) ' One method of displaying the results is to place the results table in a dataset and then pass ' that dataset to DisplayResults. This method will result in default formatting of the resulting ' TaskResultNodes Dim resultsDataSet As System.Data.DataSet = New System.Data.DataSet("Results") resultsDataSet.Tables.Add(resultsTable) TaskResults1.DisplayResults(Nothing, Nothing, Nothing, resultsDataSet) ' An alternative method of displaying the table is to explictly create TaskResultNodes. This ' method allows custom configuration of those nodes, providing control over behaviors such as ' node expansion '// Create a parent node for the results and assign it a remove-only context menu 'ESRI.ArcGIS.ADF.Web.UI.WebControls.TaskResultNode headingTaskResultNode = ' new ESRI.ArcGIS.ADF.Web.UI.WebControls.TaskResultNode(string.Format("Results ({0})", ' resultsTable.Rows.Count)); 'TaskResults1.SetupContextMenu(TaskResults1.RemoveOnlyContextMenu, headingTaskResultNode); '// Create a node with the results data table 'ESRI.ArcGIS.ADF.Web.UI.WebControls.TreeViewPlusNode resultsTreeViewPlusNode = ' TaskResults1.CreateDataTableNode(resultsTable, true, false, true, null, "Query Results"); '// Expand the data node and assign it a remove-only context menu 'resultsTreeViewPlusNode.Expanded = true; 'TaskResults1.SetupContextMenu(TaskResults1.RemoveOnlyContextMenu, resultsTreeViewPlusNode); '// Add the data node under the parent node and call EnsureVisible to make sure the parent node '// is not collapsed. Note that EnsureVisible needs to be called after the node is added. 'headingTaskResultNode.Nodes.Add(resultsTreeViewPlusNode); 'resultsTreeViewPlusNode.EnsureVisible(); '// Display the custom node by passing it to DisplayResults 'TaskResults1.DisplayResults(null, null, null, headingTaskResultNode); ' Copy the TaskResults control's callback results to the Toolbar so they are processed ' on the client Toolbar1.CallbackResults.CopyFrom(TaskResults1.CallbackResults) End Select End Sub End Class