手拼Table 前台显示

时间:2023-03-09 14:36:20
手拼Table 前台显示

一:前台

 <table border="" cellpadding="" cellspacing="" width="100%" id="TblList" runat="server" bordercolor="#D6DFF7">
</table>

二:后台

 //表头
public void TABTITLE()
{
TblList.Rows.Clear(); HtmlTableRow Row;
HtmlTableCell Cell; Row = new HtmlTableRow();
Row.Attributes.Add("align", "center"); Cell = new HtmlTableCell();
Cell.Attributes.Add("align", "center");
Cell.RowSpan = ;
Cell.InnerHtml = "编 号";
Row.Cells.Add(Cell); Cell = new HtmlTableCell();
Cell.Attributes.Add("align", "center");
Cell.RowSpan = ;
Cell.InnerHtml = "标 题";
Row.Cells.Add(Cell); Cell = new HtmlTableCell();
Cell.Attributes.Add("align", "center");
Cell.RowSpan = ;
Cell.InnerHtml = "发送时间";
Row.Cells.Add(Cell); Cell = new HtmlTableCell();
Cell.Attributes.Add("align", "center");
Cell.RowSpan = ;
Cell.InnerHtml = "部 门";
Row.Cells.Add(Cell); TblList.Rows.Add(Row);
}
 public void Bind(string sqlwhere)
{
TABTITLE();
DataSet ds = GetData(sqlwhere); int n = ds.Tables[].Rows.Count;
int i = ;
for (i = ; i < n; i++)
{ HtmlTableRow Row;
HtmlTableCell Cell; Row = new HtmlTableRow();
Row.Attributes.Add("align", "center");
Row.Attributes.Add("bgcolor", "white"); Cell = new HtmlTableCell();
Cell.InnerHtml = (i + ).ToString();
Row.Cells.Add(Cell); Cell = new HtmlTableCell();
Cell.InnerHtml = ds.Tables[].Rows[i]["title"].ToString();
Row.Cells.Add(Cell); Cell = new HtmlTableCell();
Cell.InnerHtml = ds.Tables[].Rows[i]["ngrq"].ToString();
Row.Cells.Add(Cell); Cell = new HtmlTableCell();
Cell.InnerHtml = ds.Tables[].Rows[i]["uname"].ToString();
Row.Cells.Add(Cell); TblList.Rows.Add(Row);
} }