// Spludlow Software // Copyright © Samuel P. Ludlow 2020 All Rights Reserved // Distributed under the terms of the GNU General Public License version 3 // Distributed WITHOUT ANY WARRANTY; without implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE // https://www.spludlow.co.uk/LICENCE.TXT // The Spludlow logo is a registered trademark of Samuel P. Ludlow and may not be used without permission // v1.14 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class Render_DataItem : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } public DataSet _DataSet = null; public void Display(object data) { this.LiteralText.Visible = true; if (data == null) { this.LiteralText.Text = "NULL"; return; } Type type = data.GetType(); if (typeof(DataSet).IsAssignableFrom(type) == true) { this.LiteralText.Visible = false; this.DataListData.Visible = true; this._DataSet = (DataSet)data; DataTable tables = Spludlow.Data.TextTable.ReadText(new string[] { "TableName", "String*", }); foreach (DataTable table in this._DataSet.Tables) tables.Rows.Add(new object[] { table.TableName }); this.DataListData.DataSource = tables; this.DataListData.DataBind(); return; } // Need improvment here !!!!!!! this.LiteralText.Text = Convert.ToString(data); } protected void DataListData_ItemDataBound(object sender, DataListItemEventArgs e) { DataRow tableRow = ((DataRowView)e.Item.DataItem).Row; string tableName = (string)tableRow["TableName"]; GridView gridView = (GridView)e.Item.FindControl("GridViewTable"); Literal literal = (Literal)e.Item.FindControl("LiteralTable"); literal.Text = tableName + " (" + this._DataSet.Tables[tableName].Rows.Count + ")"; gridView.DataSource = this._DataSet.Tables[tableName]; gridView.DataBind(); } }