using System;
using System.Data;
using System.Collections;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CMS.FormEngine;
using CMS.GlobalHelper;
using CMS.SettingsProvider;
using CMS.SiteProvider;
using CMS.UIControls;
public partial class CMSModules_CustomTables_Controls_CustomTableViewItem : CMSUserControl
{
#region "Variables"
private CustomTableItem mCustomTableItem;
#endregion
#region "Properties"
public CustomTableItem CustomTableItem
{
get
{
return mCustomTableItem;
}
set
{
mCustomTableItem = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (CustomTableItem != null)
{
StringBuilder sb = new StringBuilder();
DataClassInfo dci = DataClassInfoProvider.GetDataClass(CustomTableItem.CustomTableClassName);
if (dci != null)
{
sb.Append("
");
// Get class form definition
FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, false);
string fieldCaption = "";
FormFieldInfo ffi = null;
IDataContainer item = CustomTableItem;
// Table header
string headerContent = "| " + GetString("customtable.data.nametitle") + " | " + GetString("customtable.data.namevalue") + " |
";
sb.Append(headerContent);
// Go through the columns
int i = 0;
foreach (string columnName in item.ColumnNames)
{
// Get field caption
ffi = fi.GetFormField(columnName);
if (ffi == null)
{
fieldCaption = columnName;
}
else
{
if (ffi.Caption == "")
{
fieldCaption = columnName;
}
else
{
fieldCaption = ResHelper.LocalizeString(ffi.Caption);
}
}
string className = ((i % 2) == 0) ? "EvenRow" : "OddRow";
string rowContent = "| {0} | {1} |
";
sb.Append(String.Format(rowContent, fieldCaption, HTMLHelper.HTMLEncode(ValidationHelper.GetString(item.GetValue(columnName), ""))));
++i;
}
sb.Append("
");
}
string resultTable = sb.ToString();
if (!string.IsNullOrEmpty(resultTable))
{
ltlContent.Text = resultTable;
}
}
else
{
ltlContent.Text = GetString("editedobject.notexists");
return;
}
}
}