向表中添加新行

时间:2011-07-23 08:17:33

标签: c# asp.net

 HtmlTable baseCalendar = new HtmlTable();
 HtmlTableRow calendarRow = new HtmlTableRow();
 HtmlTableCell calendarCell = new HtmlTableCell();

 for (int i = 1; i < 7; i++)
 {
     calendarRow = new HtmlTableRow();

     for (int k = 0; k < 7; k++)
     {
         calendarCell = new HtmlTableCell();
         calendarRow.Cells.Add(calendarCell);
     }     

     baseCalendar.Rows.Add(calendarRow);                
 }
 //in this place how can add new row to first row of `baseCalendar`

例如:

 baseCalendar="
 <table>
   <tr id='row1'>
      <td></td>
      <td></td>
   </tr>
 </table>"

如何在row1

之前添加新行

1 个答案:

答案 0 :(得分:0)

您可以使用Insert方法,如下所示:

...
HtmlTableRow headers = new HtmlTableRow();
headers.Cells.Add(new HtmlTableCell("sat"));
...

baseCalendar.Rows.Insert(1, headers);