因此创建一个数据表并遍历其中的所有行。麻烦是DataRow r包含一个itemArray [],我也需要运行它。
DataTable currentAttribs = //results for datatable;
foreach (DataRow r in currentAttribs.Rows)
{
//foreach itemArray[] in r do the following
{
tableRow = "<TR><TD>" + r[0].ToString() + "</TD></TR>";
Literal lc = new Literal();
lc.Text = tableRow;
divFeatureInfo.Controls.Add(lc);
{
}
不确定在'r'中运行itemArray的语法...谢谢
答案 0 :(得分:1)
ItemArray
是Object[]
:
foreach (DataRow r in currentAttribs.Rows)
{
foreach (Object obj in r.ItemArray)
{
string tableRow = string.Format("<TR><TD>{0}</TD></TR>", r[0]);
Literal lc = new Literal();
lc.Text = tableRow;
divFeatureInfo.Controls.Add(lc);
// do whatever you need to do with obj
}
}