using System;
using System.Web.UI.WebControls;
using CMS.GlobalHelper;
using CMS.UIControls;
public partial class CMSModules_ContactManagement_Controls_UI_ActivityDetails_DetailsList : CMSUserControl
{
#region "Variables"
private Table tbl = new Table();
private bool mHideEmptyValues = true;
#endregion
#region "Public properties"
///
/// If true, empty values is hidden/ignored.
///
public bool HideEmptyValues
{
get
{
return mHideEmptyValues;
}
set
{
mHideEmptyValues = value;
}
}
///
/// Returns true, if detilas list is not empty.
///
public bool IsDataLoaded
{
get
{
return (tbl.Rows.Count > 0);
}
}
#endregion
#region "Methods"
protected void Page_Load(object sender, EventArgs e)
{
tbl.ID = ID + "tbl";
plc.Controls.Add(tbl);
}
///
/// Creates/adds new row to table.
///
/// Label text (resource string)
/// Value (will be encoded)
public void AddRow(string label, string value)
{
AddRow(label, value, true);
}
///
/// Creates/adds new row to table.
///
/// Label text (resource string)
/// Value
/// Set tu true if value should be encoded
public void AddRow(string label, string value, bool encode)
{
if (encode)
{
value = HTMLHelper.HTMLEncode(value);
}
AddRow(label, value, "ActivityDetailsLabel", null, true);
}
///
/// Creates/adds new row to table.
///
/// Label text (resource string)
/// Value (will be encoded)
/// CSS class for label cell
/// CSS class for value cell
public void AddRow(string label, string value, string labelCssClass, string valueCssClass, bool DisplayColon)
{
if (HideEmptyValues && String.IsNullOrEmpty(value))
{
return;
}
label = GetString(label);
if (DisplayColon)
{
label += GetString("general.colon");
}
int i = tbl.Rows.Count;
TableRow tr = new TableRow();
tr.Cells.Add(CreateTableCell("cell0" + i, label, labelCssClass));
tr.Cells.Add(CreateTableCell("cell1" + i, value, valueCssClass));
tbl.Rows.Add(tr);
}
///
/// Creates new cell.
///
/// Cell ID
/// Cell text
/// CSS class
private TableCell CreateTableCell(string id, string text, string cssClass)
{
TableCell tc = new TableCell();
tc.ID = id;
tc.CssClass = cssClass;
tc.Text = text;
return tc;
}
#endregion
}