Multiple TableCell.Conrols.Add(control) - How <BR> between them?

  • Thread starter Thread starter Craig
  • Start date Start date
C

Craig

I'm adding several controls to a cell, but want them all to have a <BR>
between them. What's the easiest way?

I'm doing something like this:

HyperLink link = new Hyperlink();
//I setup the link target, navigateurl, etc here
Label lblDescription = new Label();
//I setup the lblDescription.Text here
Label lblName = new Label();
//I setup the lblName.Text here

TableCell cell = new TableCell();
cell.Controls.Add(link);
cell.Controls.Add(lblDescription);
cell.Controls.Add(lblName);


Now all the controls are just run together. Is there a property on the
controls to set to include <BR> after them? doing something like cell.Text
+= "<BR>" between them doesn't work, it erases to content of the cell...

Thanks in advance for the help,
Craig
 
Craig said:
I'm adding several controls to a cell, but want them all to have a <BR>
between them. What's the easiest way?

TableCell cell = new TableCell();
cell.Controls.Add(link);
cell.Controls.Add(lblDescription);
cell.Controls.Add(lblName);

Hello Craig,

Between adding the link and lblDescription
and between adding the lblDescription and lblName,
you can add LiteralControls that contain the "<BR>".

Best regards,

Eric
 
You can set up a System.Web.UI.WebControls.Literal object to have the text
"<br/>" and then add this control to the controls collection of the cell.
 
Thanks guys - I have overlooked the literal control all this time
apparently... it works great.
 
Back
Top