0

我想在我的动态表中显示数据表值,我循环了一遍,但我不能成功。dtplants 是我的数据表。你能帮我用下面的代码吗?

        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(); 
    }
4

1 回答 1

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>");
于 2012-10-04T13:07:14.410 回答