标签:
一:前台
1 <table border="1" cellpadding="3" cellspacing="1" width="100%" id="TblList" runat="server" bordercolor="#D6DFF7">
2</table>
二:后台
1 //表头 2 public void TABTITLE() 3 { 4 TblList.Rows.Clear(); 5 6 HtmlTableRow Row; 7 HtmlTableCell Cell; 8 9 Row = new HtmlTableRow(); 10 Row.Attributes.Add("align", "center"); 11 12 Cell = new HtmlTableCell(); 13 Cell.Attributes.Add("align", "center"); 14 Cell.RowSpan = 1; 15 Cell.InnerHtml = "编 号"; 16 Row.Cells.Add(Cell); 17 18 Cell = new HtmlTableCell(); 19 Cell.Attributes.Add("align", "center"); 20 Cell.RowSpan = 1; 21 Cell.InnerHtml = "标 题"; 22 Row.Cells.Add(Cell); 23 24 Cell = new HtmlTableCell(); 25 Cell.Attributes.Add("align", "center"); 26 Cell.RowSpan = 1; 27 Cell.InnerHtml = "发送时间"; 28 Row.Cells.Add(Cell); 29 30 Cell = new HtmlTableCell(); 31 Cell.Attributes.Add("align", "center"); 32 Cell.RowSpan = 1; 33 Cell.InnerHtml = "部 门"; 34 Row.Cells.Add(Cell); 35 36 TblList.Rows.Add(Row); 37 }
1 public void Bind(string sqlwhere) 2 { 3 TABTITLE(); 4 DataSet ds = GetData(sqlwhere); 5 6 int n = ds.Tables[0].Rows.Count; 7 int i = 0; 8 for (i = 0; i < n; i++) 9 { 10 11 HtmlTableRow Row; 12 HtmlTableCell Cell; 13 14 Row = new HtmlTableRow(); 15 Row.Attributes.Add("align", "center"); 16 Row.Attributes.Add("bgcolor", "white"); 17 18 Cell = new HtmlTableCell(); 19 Cell.InnerHtml = (i + 1).ToString(); 20 Row.Cells.Add(Cell); 21 22 Cell = new HtmlTableCell(); 23 Cell.InnerHtml = ds.Tables[0].Rows[i]["title"].ToString(); 24 Row.Cells.Add(Cell); 25 26 Cell = new HtmlTableCell(); 27 Cell.InnerHtml = ds.Tables[0].Rows[i]["ngrq"].ToString(); 28 Row.Cells.Add(Cell); 29 30 Cell = new HtmlTableCell(); 31 Cell.InnerHtml = ds.Tables[0].Rows[i]["uname"].ToString(); 32 Row.Cells.Add(Cell); 33 34 TblList.Rows.Add(Row); 35 } 36 37 38 }
标签:
原文地址:http://www.cnblogs.com/fjptwwf/p/5416940.html