PDA

View Full Version : server side tables


TonyMast
10-23-2004, 06:18 AM
I'm getting some weird results using server side tables.

Can Controls be added to server tables at design time?

How can I make the cells staic in size I set them? (Not autosizing)

Why when I use table.rows(2).cell(1).controls.remove(label1), this removes all controls from the table?

Thanks
Tony



Thank you
Tony

lu8890
02-25-2005, 05:08 AM
Hi, have you try to use System.Web.UI.WebControls.Table?
I used it to generate public forum on my website, and it works great.
here is the example...

//Fill in dynamic Table contents here.

//Create Row1
TableRow r = new TableRow();
r.BackColor = Color.AntiqueWhite;
TableCell c = new TableCell();
c.Controls.Add(new LiteralControl("Message ID: " + id ));
r.Cells.Add(c);
TableCell c2 = new TableCell();
c2.Controls.Add(new LiteralControl("From: " + alias));
r.Cells.Add(c2);
mytable2.Rows.Add(r);

//Create Row 2
TableRow r2 = new TableRow();
r2.BackColor = Color.AliceBlue;
TableCell c3 = new TableCell();
c3.Controls.Add(new LiteralControl("Date: " + date));
r2.Cells.Add(c3);
TableCell c4 = new TableCell();
c4.Controls.Add(new LiteralControl("Time: " + time));
r2.Cells.Add(c4);
mytable2.Rows.Add(r2);

//Create Row 3 - Created a listbox control, and insert the control into the tablecell.
TableRow r3 = new TableRow();
TableCell c5 = new TableCell();

TextBox t1 = new TextBox();
t1.Text = content;
t1.TextMode = TextBoxMode.MultiLine;
t1.Width = 744;
t1.Height = 199;
t1.ReadOnly = true;
c5.Controls.Add(t1);
c5.ColumnSpan = 2;
r3.Cells.Add(c5);
mytable2.Rows.Add(r3);


hope this helps. ^^


Tommy