benjamin54
benjamin54

Reputation: 1300

Showing multiple user controls in table

I'm creating a table from code behind file.

MyControl control1 = (MyControl)Page.LoadControl("MyControl.ascx");
control1.ID = "ctl1";
MyControl control2 = (MyControl)Page.LoadControl("MyControl.ascx");
control2.ID = "ctl2";
MyControl control3 = (MyControl)Page.LoadControl("MyControl.ascx");
control3.ID = "ctl3";
MyControl control4 = (MyControl)Page.LoadControl("MyControl.ascx");
control4.ID = "ctl4";

Table table = new Table();

TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
TableRow row1 = new TableRow();

cell1.Controls.Add(control1);
row1.Cells.Add(cell1);
cell2.Controls.Add(control2);
row1.Cells.Add(cell2);
cell3.Controls.Add(control3);
row1.Cells.Add(cell3);
cell4.Controls.Add(control4);
row1.Cells.Add(cell4);

table.Rows.Add(row1);
placeHolder1.Controls.Add(table);

But I see only first control gets loaded, others not. Anything missing?

Upvotes: 0

Views: 246

Answers (1)

nunespascal
nunespascal

Reputation: 17724

Your controls are there all right.
Your CSS position fixed is causing them to overlap.

I created a jsfiddle to demonstrate what is happening.

You can only see the gauge that in the last cell.

It can be fixed by removing the position: fixed

See this jsfiddle solution.

Upvotes: 1

Related Questions