I’m sure I’ve come across this before, but I’m writing this down so that I don’t forget it later.
I’m working with a pretty hefty custom GridView and it’s really trying my patience for this control. Yeah yeah, it’s all great if you want to bind a list of data coming from a SQL Query written in your aspx in plain-text. The minute you start to customize it all that goodness turns into a mess of weird templating and strange quirks about ASP.NET, but I digress.
Anyway, this post relates to the fact that the TableCell class has a Text property and a controls collection.
If you are creating custom rows of data, you have to choose between doing
1
| |
or
1
| |
The difference is that the two are mutually exclusive. If you have controls inside the table cell, then the Text property will be empty. If you have the Text property set, then there can’t be any controls.
So in my case I was setting the Text property, then trying to insert a LinkButton control right before the text. So I diligently put
1
| |
Which happily wipes everything that was previously in the Text property. Ugh.