TableCell.Text property is ignored if there are child controls

I wanted to dynamically create content of ASP.NET TableCell control. It should have some text and image.
I've tried to use the code

cell.Text = "Text";
cell.AddControls(imgControl);
 

But the text wasn't shown. The reason is that if TableCell has child controls, the text value is ignored during rendering. See TableCell.RenderContents in Reflector.

The valid way is the following:
Label lbl=new Label();
lbl.Text=text;
cell.Controls.Add(lbl);
cell.AddControls(imgControl).

posted @ Thursday, January 10, 2008 11:03 AM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 7 and 8 and type the answer here:
 

Live Comment Preview:

 
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910