Click here to Skip to main content
Rate this: bad
good
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
Ruwaldo733
Edited 13-Nov-12 4:42am
(no name)18.1K
v2
Comments
ryanb31 at 13-Nov-12 10:00am
   
I have not tested your code but can you explain where you are stuck?
Ruwaldo at 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
0 Sergey Alexandrovich Kryukov 269
1 OriginalGriff 180
2 DamithSL 180
3 Peter Leow 125
4 Kornfeld Eliyahu Peter 95
0 OriginalGriff 7,355
1 DamithSL 5,254
2 Sergey Alexandrovich Kryukov 4,942
3 Maciej Los 4,906
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2014
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