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

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
 
E

Eric Veltman

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
 
C

Chris Jackson

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.
 
C

Craig

Thanks guys - I have overlooked the literal control all this time
apparently... it works great.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top