English 中文(简体)
数据表
原标题:DataTable Array onto a Table Control

请允许我说,我有一系列的<代码> 可使用[。 在每个数据表中,最多有5行。 每个行各有5列。 我需要在一份5×5的html表中显示数据表的内容,以便从数据表到另一个表(即td)的电池之间有1到1的关系。

谁能给我一条关于如何实现这一目标的法典? 它需要通过可数据阵列的长度。 因此,如果有3个数据表,则需要编制3个表格。

我数据表实例

Row 1 : Colors, Sizes, Length
Row 2 : Blue  ,   L  , 23
Row 3 : Green ,   M  , 24
Row 4 : Red   ,   S  , 25
Row 5 : Yellow,      , 26
最佳回答

ok,这里是一些法典。 我没有把它汇编成册,因此可能会有打字......但我想象,它将使你走正确的方向。 3 nes。

StringBuilder html = new StringBuilder();

foreach(DataTable aTable in tableList)
{
   html.Append("<table>");

   foreach(DataRow row in aTable.rows)
   {
      html.Append("<tr>");

      foreach(string cell in row.Items)
      {
         html.Append("<td>");

         if (cell == null)
            html.Append("&nbsp;");
         else
            html.Append(cell);

         html.Append("</td>");
      }

      html.Append("</tr>");
   }

   html.Append("</table>");
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签