日期:2014-05-18 浏览次数:20592 次
/// <summary> /// 加载Table(根据参数加载行数) /// </summary> /// <param name="iRow">需要加载的行数</param> private void InitTable(int iRow, int iTable) { TableCell td; for (int i = 0; i < iRow; i++) { TableRow tr = new TableRow(); td = new TableCell(); td.ID = "ColId" + i + 1; //设置第一个单元格的ID td.Text = (iTable + i).ToString(); //设置第一个单元格文本 td.Width = Unit.Pixel(60); tr.Cells.Add(td); //设置第二个单元格的ID和单元格文本 提交时间 td=new TableCell(); td.ID = "ColDate" + i + 1; td.Text = DateTime.Now.ToString("yyyy-MM-dd"); td.Width = Unit.Point(120); tr.Cells.Add(td); //设置第三个单元格的ID和单元格文本 提交人 td = new TableCell(); td.ID = "ColAuthor" + i + 1; TextBox txtAuthor = new TextBox(); txtAuthor.Width = Unit.Pixel(120); txtAuthor.ID = "txtAuthor" + i.ToString(); td.Controls.Add(txtAuthor); td.Width = Unit.Point(120); tr.Cells.Add(td); //设置第四个单元格的ID和单元格文本 金额 td = new TableCell(); td.ID = "ColMoney" + i + 1; TextBox txtMoney = new TextBox(); txtMoney.ID = "txtMoney" + i.ToString(); txtMoney.Width = Unit.Pixel(100); td.Controls.Add(txtMoney); td.Width = Unit.Point(100); tr.Cells.Add(td); //设置第五个单元格的ID和单元格文本 审核依据 td = new TableCell(); td.ID = "ColPayment" + i + 1; TextBox txtPayment = new TextBox(); txtPayment.ID = "txtPayment" + i.ToString(); txtPayment.Width = Unit.Pixel(200); td.Controls.Add(txtPayment); td.Width = Unit.Point(200); tr.Cells.Add(td); Table1.Rows.Add(tr); } iRow = Table1.Rows.Count; } /// <summary> /// 新增行按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { int irow = Convert.ToInt32(ViewState["iRow"]); irow = int.Parse(txt1.Text); InitTable(1, irow); }