我是在運行時先對table1進行數據填充再對table2進行數據填充,主要代碼如下:
private void FillTable()
{
FillTable1();
FillTable2();
}
private void FillTable1()
{
      while(drTh.Read())
      {
         TableRow row=new TableRow();
TableCell cell = new TableCell();
cell.Text=drTh["ph"].ToString();
row.Cells.Add(cell);
cell=new TableCell();
         cell.Text =drTh["khph"].ToString();
row.Cells.Add(cell);
         Tchuhuodanmx.Rows.Add(row);   
}    
drTh.Close();
}
private void FillTable2()
{
while(drChh.Read())
{
TableRow row=new TableRow();
TableCell cell = new TableCell();
cell.Text=drChh["ph"].ToString();
row.Cells.Add(cell);
Ttuihuodanmx.Rows.Add(row);
         }        
         drChh.Close();
}