using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// ActiveTable 动态生成表格
/// </summary>
public class ActiveTable
{
/// <summary>
/// 构造函数
/// </summary>
public ActiveTable()
{
}
/// <summary>
/// 申明私有字段
/// </summary>
public object[,] m_Info;//信息内容
public object[] m_Title;//表格标题
public int m_Rows;//行数
public int m_Columns = 0;//列数
public string m_tbWidth; //表格宽度
public string m_border = "1";//表格边界
public string m_cellpadding = "0";
public string m_fontSize = "18px;";//字体大小
public string m_cellspacing = "0";
public string m_TitlebackgroundColor = "White";//标题背景色
public string m_backgroundColor = "White";//行的颜色
public string m_align = "left";
public bool m_isNeedTitle = true;//是否需要表头
public string m_strWidth = "";//列的宽度
public string m_ColumnCss="BORDER-TOP-STYLE: none";
//public bool m_IsHaveChoiceControl;//是否显示选择控件
//public bool m_ShowHcbxOrShowHrdo;//显示复选控件还是单选控件
//public bool m_IsSetShowDetialInfo;//是否设置详细信息连接
//public bool m_IsHaveChoiceControl;//是否显示选择控件
//public string m_OtherUrl;//其他连接URL
//public string m_tbWidth; //表格宽度
//public bool m_IsSetOtherHerf;//是否设置其他连接操作
//public bool m_ShowHcbxOrShowHrdo;//显示复选控件还是单选控件
//public bool m_IsSetShowDetialInfo;//是否设置详细信息连接
//public string m_DetialInfoUrl;//详细信息连接的URL
//public bool m_IsHaveChoiceControl;//是否显示选择控件
//public string m_strLinkName;//其他连接的名称
//public string m_strLinkNameTitle;//其他连接名称的表格标题
/// <summary>
/// 创建动态表格
/// </summary>
/// <returns></returns>
public string CreateActiveTable()
{
string strTotal = "";
strTotal = "<table width='" + m_tbWidth + "' border='" + m_border + "' cellspacing='" + m_cellspacing + "' cellpadding='" + m_cellpadding + "' style=/"text-align:center; font-size:" + m_fontSize + "/" >";
if (m_isNeedTitle == true)
{
for (int i = 1; i <= m_Rows; i++)
{
strTotal += "<tr >";
for (int iCloum = 0; iCloum < m_Columns; iCloum++)
{
if (i == 1)
{
strTotal += "<td style='height:25px;background-color:" + m_TitlebackgroundColor + "' width='" + m_strWidth + "'>";
strTotal += m_Title[iCloum];
strTotal += "</td>";
}
else
{
if (i % 2 == 0)
strTotal += "<td style='background-color:" + m_backgroundColor + "'>";
else
strTotal += "<td>";
strTotal += m_Info[i - 2, iCloum];
strTotal += "</td>";
}
}
strTotal += "</tr>";
}
}
else
{
for (int i = 1; i <= m_Rows - 1; i++)
{
strTotal += "<tr>";
for (int iCloum = 0; iCloum < m_Columns; iCloum++)
{
if (i % 2 == 0)
strTotal += "<td style='"+m_ColumnCss+";background-color:" + m_backgroundColor + "' width='" + m_strWidth + "'>";
else
strTotal += "<td style='"+m_ColumnCss+"' width='" + m_strWidth + "'>";
strTotal += m_Info[i - 1, iCloum];
strTotal += "</td>";
}
strTotal += "</tr>";
}
}
strTotal = strTotal + "</table>";
return (strTotal);
}
}