Click here to Skip to main content
12,625,402 members (36,190 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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.


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 13-Nov-12 4:27am
Ruwaldo735
Updated 13-Nov-12 4:42am
v2
Comments
ryanb31 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100