通过itemArray运行

时间:2014-12-08 09:48:13

标签: c# asp.net asp.net-mvc

因此创建一个数据表并遍历其中的所有行。麻烦是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的语法...谢谢

1 个答案:

答案 0 :(得分:1)

ItemArrayObject[]

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
    }
}