2014-12-08 19 views
0

因此,創建一個數據表並通過其中的所有行運行。麻煩的是DataRow包含一個itemArray [],我也需要運行它。運行一個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); 
      { 
      } 

不確定的語法通過itemArray在「R」運行...感謝

回答

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

實際上是想我應該嘗試,當我寫出Q..duh ....感謝回覆,儘管歡呼蒂姆 – John 2014-12-08 09:53:26

+1

- 保持世界和平! – John 2014-12-08 10:32:13