【发布时间】:2015-02-06 02:17:10
【问题描述】:
是我要找的输出,左边是表头,右边是对应的数据....
一旦我到达foreach (DataColumn c in dr.Table.Columns) 的结尾,是否可以说 - 回到第一行第二列?
foreach (DataRow dr in currentAttribs.Rows)
{
foreach (DataColumn c in dr.Table.Columns)
{
headerRow = "<tr><th>" + c.ColumnName.ToString() + "</th></tr><br><br>";
Literal lcl = new Literal();
lcl.Text = headerRow;
divFeatureInfo.Controls.Add(lcl);
}
foreach (object column in dr.ItemArray)
{
tableRow = "<TR><TD>" + column.ToString() + "</TD></TR><br><br>";
Literal lc = new Literal();
lc.Text = tableRow;
divFeatureInfo.Controls.Add(lc);
}
}
这段代码给了我输出:
id
Geom
Day
05
489090
Monday
我想要:
id 05
Geom 489090
Day Monday
感谢任何回复
【问题讨论】:
-
您知道您将拥有多少列吗?如果是这样,对列使用 for 循环,对其中的行使用循环
-
总是 2 列是的,但可以是任意数量的行
标签: c# html html-table