62,046
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
public partial class 后台_Default2 : System.Web.UI.Page
{
TableHeaderRow thr = new TableHeaderRow();
TableRow tr = new TableRow();
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 64; i <= 84; i++)
{
addTableHeaderRow(i);
}
for (int a = 0; a < 5; a++)
{
addRowsCount(Table1,a);
for (int c = 0; c < 20; c++)
{
addrows(Table1);
}
}
}
private void addTableHeaderRow(int i)
{
if (i==64)
{
thr.TableSection = TableRowSection.TableHeader;
TableHeaderCell thc = new TableHeaderCell();
thc.Text = "<br/>";
thc.Width = 60;
thr.Cells.Add(thc);
Table1.Rows.Add(thr);
}
else
{
ASCIIEncoding asce = new ASCIIEncoding();
byte[] bytea = new byte[] { (byte)i};
thr.TableSection = TableRowSection.TableHeader;
TableHeaderCell thc = new TableHeaderCell();
thc.Text = asce.GetString(bytea);
thc.Width = 60;
thr.Cells.Add(thc);
Table1.Rows.Add(thr);
}
}
private void addRowsCount(Table table,int a)
{
TableRow tr = new TableRow();
TableCell tc1 = new TableCell();
tc1.Text =Convert.ToString(a+1);
tr.Cells.Add(tc1);
table.Rows.Add(tr);
Label1.Text = Convert.ToString(Table1.Rows.Count);
}
private void addrows(Table table)
{
TableCell tc1 = new TableCell();
TextBox t1 = new TextBox();
t1.ID = "t" + Table1.Rows.Count;
t1.Width = 60;
tc1.Controls.Add(t1);
tr.Cells.Add(tc1);
table.Rows.Add(tr);
}
}