Common_QueryNewWindow_CSharp\TableDialog.aspx.cs
// 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. // public partial class TableDialog : System.Web.UI.Page { protected void Page_Load(object sender, System.EventArgs e) { try { // Get the random table id from the url's query string string id = Request.QueryString["id"]; // Using the table id, retrieve the results data table from session string tableSessionKey = string.Format("dataTable{0}", id); System.Data.DataTable resultsDataTable = (System.Data.DataTable)Session[tableSessionKey]; // Make sure the data table was found if (resultsDataTable != null) { // Get the HTML form and div elements to add the results data table to System.Web.UI.HtmlControls.HtmlForm htmlForm = (System.Web.UI.HtmlControls.HtmlForm)Page.FindControl("form1"); System.Web.UI.Control resultsDiv = htmlForm.FindControl("resultsDiv"); // Create a new GridView control, bind the results data table to it, display it, // and add it to the results div System.Web.UI.WebControls.GridView resultsGridView = new System.Web.UI.WebControls.GridView(); resultsGridView.DataSource = resultsDataTable; resultsGridView.DataBind(); resultsGridView.Visible = true; resultsGridView.BorderWidth = 10; resultsDiv.Controls.Add(resultsGridView); } } catch (System.Exception exception) { string jsAlertError = string.Format("<script>{0}</script>", GetJavaScriptErrorString(exception)); Response.Write(jsAlertError); } } // Constructs JavaScript necessary to display an error message based on the passed-in exception. private string GetJavaScriptErrorString(System.Exception exception) { // Get the website's configuration file System.Configuration.Configuration webConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration( System.Web.HttpContext.Current.Request.ApplicationPath); // Get the "compilation" section of the config file System.Web.Configuration.CompilationSection compilationSection = webConfig.GetSection("system.web/compilation") as System.Web.Configuration.CompilationSection; // If the config file's compilation section specifies debug mode, include // stack trace information in the error message. Otherwise, just return // the exception message. string errorMessage = null; if ((compilationSection != null) && (compilationSection.Debug)) { string stackTrace = exception.StackTrace.Replace("\\", "\\\\"); errorMessage = exception.Message + "\\n\\n" + stackTrace.Trim(); } else errorMessage = exception.Message; // Create a callback result to display an error message string jsAlertException = "alert('" + errorMessage + "')"; return jsAlertException; } }