2012-10-04 72 views
0

我想在我的動態表顯示數據表中的值,我環thourough但我不能succeeded.dtplants是我datatable.Can請你幫我用下面的代碼。創建數據表動態表顯示值與.Append財產

 StringBuilder builder = new StringBuilder(); 
     builder.Append("<table class=table1>"); 
     builder.Append("<thead>"); 
     builder.Append("<th>Configuration</th>"); 
     builder.Append("<th>Key Figures</th>"); 
     for (int i = 0; i < numberofplants; i++) 
     { 
      builder.Append("<th>"); 
      builder.Append(Convert.ToString(dtplants.Rows[i])); 
      builder.Append("</th>");    
     } 
     builder.Append("<thead>"); 
     builder.Append("<table>"); 

     Literal1.Text = builder.ToString(); 
    } 

回答

0

您必須調整end tags以關閉表

....  
    builder.Append("</thead>"); 
    builder.Append("</table>"); 

您的代碼

StringBuilder builder = new StringBuilder(); 
    builder.Append("<table class=table1>"); 
    builder.Append("<thead>"); 
    builder.Append("<th>Configuration</th>"); 
    builder.Append("<th>Key Figures</th>"); 
    for (int i = 0; i < numberofplants; i++) 
    { 
     builder.Append("<th>"); 
     builder.Append(Convert.ToString(dtplants.Rows[i])); 
     builder.Append("</th>");    
    } 
    builder.Append("</thead>"); 
    builder.Append("</table>"); 
+0

我沒有,但現在值System.Data.DataRow.I想我有與builder.Append麻煩(Convert.ToString(dtplants.Rows [i])); –

+0

任何人都可以幫忙嗎? –

+0

我'對不起ASIL您可以只添加數據dtplants.Rows [i] [j] –