table循环显示记录

  // Total number of rows
   int rowCnt;
   // Current row count
   int rowCtr;
   // Total number of cells per row (columns)
   int cellCtr;
   // Current cell counter
   int cellCnt;


   rowCnt = int.Parse(TextBox1.Text);
   cellCnt = int.Parse(TextBox2.Text);
   

   for(rowCtr=1; rowCtr <= rowCnt; rowCtr++)
   {
    // Create new row and add it to the table.
    TableRow tRow = new TableRow();
    Table1.Rows.Add(tRow);
    for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
    {
     // Create a new cell and add it to the row.
     TableCell tCell = new TableCell();
     tRow.Cells.Add(tCell);              
     // Mock up a product ID.
     string prodID = rowCtr + "_" + cellCtr;

     // Add a literal text as control.
     tCell.Controls.Add(new LiteralControl("Buy: "));
    
     // Create Hyperlink Web Server control and add to cell
     System.Web.UI.WebControls.HyperLink h = new HyperLink();

     h.Text = rowCtr + ":" + cellCtr;
     h.NavigateUrl = "http://www.microsoft.com/china/net";
     tCell.Controls.Add(h);
    
    }
   }

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值