markknowsley
Programmer
I've got some controls in a web part, and I want to try to lay them out a in a table.
So I've got the following code:
and so on. I found reference to Table, TableRow and TableCell on the Microsoft website and presume that i could use these html-style to lay out my controls, but if I do
then the Label just vanishes if I add the control to the cell after I've added the control to the collection, and has no effect if I add the add the control to the cell before I've added it to the collection.
Has anyone else successfully achieved this - and can you tell me how?
So I've got the following code:
Code:
public override void CreateChildControls()
{
lblLabel = new Label();
lblLabel.Text = "Some Text";
this.Controls.Add(lblLabel);
txtSearch = new TextBox();
this.Controls.Add(txtSearch);
}
and so on. I found reference to Table, TableRow and TableCell on the Microsoft website and presume that i could use these html-style to lay out my controls, but if I do
Code:
Table myTable = new Table();
TableRow myRow = new TableRow();
myTable.Rows.Add(myRow);
TableCell myCell = new TableCell();
myRow.Cells.Add(myCell);
myCell.Controls.Add(lblLabel);
then the Label just vanishes if I add the control to the cell after I've added the control to the collection, and has no effect if I add the add the control to the cell before I've added it to the collection.
Has anyone else successfully achieved this - and can you tell me how?