Click here to Skip to main content
15,895,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, i'm having a problem with my asp page. I need to dynamically add a asp:Table to a asp:TableCell in another asp:Table, can anyone help me?...any help will be much appreciated, thanking you in advance. Here is the code i am using.


C#
for (int i = 1; i <= 2; i++)
{
   TableRow rw = new TableRow();
   TableCell emp = new TableCell();
   TableCell code = new TableCell();
   TableCell department = new TableCell();
   TableCell tl = new TableCell();
   tl.ColumnSpan = 23;
   TableCell hours = new TableCell();

   emp.Text = "damian hawkes";
   code.Text = "543210";
   department.Text = "IT";

   Table timeline = new Table();
   TableRow rw1 = new TableRow();
   TableRow rw2 = new TableRow();
   TableRow rw3 = new TableRow();
   TableCell cell1 = new TableCell();
   TableCell cell2 = new TableCell();
   TableCell cell3 = new TableCell();
                
   DateTime dt = DateTime.Today.Date;
   for (int x = 1; x <= 720; x++)
   {
      cell1.ID = dt.Hour + ":" + dt.Minute + ":" + dt.Second;
      cell2.ID = dt.Hour + ":" + dt.Minute + ":" + dt.Second;
      cell3.ID = dt.Hour + ":" + dt.Minute + ":" + dt.Second;
      cell3.ToolTip = dt.Hour + ":" + dt.Minute + ":" + dt.Second; 
      cell2.ToolTip = dt.Hour + ":" + dt.Minute + ":" + dt.Second; 
      cell1.ToolTip = dt.Hour + ":" + dt.Minute + ":" + dt.Second;
      rw1.Cells.Add(cell1);
      rw2.Cells.Add(cell2);
      rw3.Cells.Add(cell3);
      timeline.Rows.Add(rw1);
      timeline.Rows.Add(rw2);
      timeline.Rows.Add(rw3);
      dt = dt.AddMinutes(2.00);
   }
   tl.Controls.Add(timeline);
   hours.Text = "08:00";
   rw.Cells.Add(emp);
   rw.Cells.Add(code);
   rw.Cells.Add(department);
   rw.Cells.Add(tl);
   rw.Cells.Add(hours);
   table_common_clock.Rows.Add(rw);
}
Posted
Updated 13-Nov-12 3:42am
v2
Comments
ZurdoDev 13-Nov-12 10:00am    
I have not tested your code but can you explain where you are stuck?
Ruwaldo 14-Nov-12 1:00am    
The code actually does work, it was just that i did not set the borders for the table so it didn't show. It works fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900