111,126
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 增加记录输入项
/// </summary>
/// <param name="tempInt">当前为第几条记录(显示用)</param>
/// <param name="i">当前实际为第几条记录(生成用)</param>
private void AddRecord(int tempInt,int i)
{
//每条记录对应6行TableRow
TableRow[] tableRow = new TableRow[4];
#region row1 显示当前为第几条记录,并显示相关的删除按钮
//第一行 显示当前为第几条记录,并显示相关的删除按钮
TableRow row1 = new TableRow();
// row1.CssClass = "add_content";
row1.ID = "RecordRow1" + i.ToString();
TableCell[] tableCell1 = new TableCell[2];
//第一行第一单元格
TableCell tc10 = new TableCell();
//要重新排序时用到ID
tc10.ID = "tcSortNum" + i.ToString();
tc10.ColumnSpan = 2;
tc10.Text = "<b> 协议明细(" + tempInt.ToString() + ")</b>";
tc10.HorizontalAlign = HorizontalAlign.Left;
tableCell1[0] = tc10;
//第一行第二单元格
TableCell tc11 = new TableCell();
tc11.ColumnSpan = 2;
tc11.HorizontalAlign = HorizontalAlign.Right;
//删除按钮
LinkButton lb = new LinkButton();
lb.ID = "lbDelete" + i.ToString();
lb.Text = "删除这条明细 ";
//定义事件委托
lb.Click += new EventHandler(lb_Click);
//#FF8000
lb.ForeColor = Color.FromArgb(0xFF,0x80,0x00);
tc11.Controls.Add(lb);
tableCell1[1] = tc11;
row1.Cells.AddRange(tableCell1);
tableRow[0] = row1;
#endregion
#endregion
#region row2 显示费用类型、计价单位
TableRow row2 = new TableRow();
row2.CssClass = "add_content";
row2.ID = "RecordRow3" + i.ToString();
TableCell[] tableCell3 = new TableCell[4];
//第三行第一单元格
TableCell tc30 = this.AddTableCell(HorizontalAlign.Right,15);
tc30.Text = "费用类型:";
tableCell3[0] = tc30;
//第三行第二单元格
TableCell tc31 = this.AddTableCell(HorizontalAlign.Left,35);
DropDownList ddl = new DropDownList();
ddl.ID = "ddlPriTpID" + i.ToString();
ddl.DataTextField = "StaticName";
ddl.DataValueField = "StaticID";
ddl.DataSource = protoclKind;
ddl.DataBind();
ddl.Attributes.Add("onchange","selectChange(this,"+"'txtPriName"+i.ToString()+"')");
tc31.Controls.Add(ddl);
tableCell3[1] = tc31;
//第三行第三单元格
TableCell tc32 = this.AddTableCell(HorizontalAlign.Right,15);
tc32.Text = "计价单位:";
tableCell3[2] = tc32;
//第三行第四单元格
TableCell tc33 = this.AddTableCell(HorizontalAlign.Left,35);
this.TableCellAddTextBox(tc33,"txtUnitPrice" + i.ToString(),10);
tableCell3[3] = tc33;
row2.Cells.AddRange(tableCell3);
tableRow[1] = row2;
#endregion
#region row3 显示定价名称
TableRow row3 = new TableRow();
row3.CssClass = "add_content";
TableCell[] tableCell4 = new TableCell[2];
row3.ID = "RecordRow4" + i.ToString();
//第四行第一单元格
TableCell tc40 = this.AddTableCell(HorizontalAlign.Right,15);
tc40.Text = "定价名称:";
tableCell4[0] = tc40;
//第四行第二单元格
TableCell tc41 = this.AddTableCell(HorizontalAlign.Left,85);
this.TableCellAddTextBox(tc41,"txtPriName" + i.ToString(),100,92,ddl.Items[0].Text);
tc41.ColumnSpan = 3;
tableCell4[1] = tc41;
row3.Cells.AddRange(tableCell4);
tableRow[2] = row3;
#endregion
#region row4 显示单价、免费天数
TableRow row4 = new TableRow();
row4.CssClass = "add_content";
row4.ID = "RecordRow5" + i.ToString();
TableCell[] tableCell5 = new TableCell[4];
//第五行第一单元格
TableCell tc50 = this.AddTableCell(HorizontalAlign.Right,15);
tc50.Text = "单价:";
tableCell5[0] = tc50;
//第五行第二单元格
TableCell tc51 = this.AddTableCell(HorizontalAlign.Left,35);
this.TableCellAddTextBox(tc51,"txtPrice" + i.ToString(),20);
tableCell5[1] = tc51;
//第五行第三单元格
TableCell tc52 = this.AddTableCell(HorizontalAlign.Right,15);
tc52.Text = "免费数";
tableCell5[2] = tc52;
//第五行第四单元格
TableCell tc53 = this.AddTableCell(HorizontalAlign.Left,35);
this.TableCellAddTextBox(tc53,"txtFree" + i.ToString(),10,80,"0");
tableCell5[3] = tc53;
row4.Cells.AddRange(tableCell5);
tableRow[3] = row4;
#endregion
this.dtMain.Rows.AddRange(tableRow);
}
<asp:repeater id="Repeater1"
datasourceid="SqlDataSource1"
runat="server">
<itemtemplate>
<table border="1">
<tr>
<td><b>Product ID</b></td>
<td><b>Product Name</b></td>
</tr>
<tr>
<td> <%# Eval("ProductID") %> </td>
<td> <%# Eval("ProductName") %> </td>
</tr>
</table>
</itemtemplate>
</asp:repeater>
<asp:sqldatasource id="SqlDataSource1"
connectionstring="<%$ ConnectionStrings:NorthWindConnection%>"
selectcommand="SELECT ProductID, ProductName FROM [Products] Where ProductID <= 10"
runat="server">
</asp:sqldatasource>