c# 后台 添加datable 数据
public void AddRows(HtmlTable table(表名),DataTable dt(数据源), string i(自增长))
{
int j = int.Parse(i);
HtmlTableRow tr0 = new HtmlTableRow();
HtmlTableCell tc = new HtmlTableCell();
tc.Attributes.Add("style","font-size:14px;text-align:center;");
tc.Attributes.Add("colspan", "2");
tc.InnerText = dt.Rows[j]["sbmc"].ToString();
HtmlTableCell tc0 = new HtmlTableCell();
tc0.Attributes.Add("contentEditable", "true");
tc0.Attributes.Add("style", "font-size:14px;text-align:center;");
tc0.InnerText = dt.Rows[j]["xh"].ToString();
tc.Attributes.Add("contentEditable", "true");
tc0.Attributes.Add("contentEditable", "true");
tr0.Cells.Add(tc);
tr0.Cells.Add(tc0);
table.Rows.Insert(1, tr0);
table.Attributes.Add("border", "1");
}
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/34386.html