January 2007 Entries

This is kinda weird. I'm building a web application in ASP.Net 2.0 and I want to put a CheckBox control in a TableCell object. Should be pretty straight forward. Simply create the checkbox, set its properties, and add it to the TableCell's Controls collection. I run the app and the checkbox is not showing up. What's up with that?

Stepping through the code, I can see the checkbox in the TableCell's Controls collection right after I add it, but after I set some properties on the TableCell and add it to the TableRow object, the checkbox isn't in the collection. I figured out that when I set the Text property on the TableCell to string.Empty (or any other string), that seemed to remove the control from the TableCell. Weird. So, if I don't set the Text property on the TableCell, the checkbox shows up just fine.

I guess you can't put text and controls in a TableCell?