Ok, I know how to do this, but I want to know if this is the BEST way.
I have a table called ‘Topics’ which has a list of topics(obv). I have a page with about 20 (+/-10) check boxes with all the different topics a user can subscribe to. I figured the best way to do this is to make a control array of check boxes and populate it on page load.
The issue is that the check boxes are in a unique arrangement, should I place them on the page and then dynamically populate them on load? Is that the best way to do it? I’m not too familiar with control arrays.
Thanks!
Define what you mean by ‘should I place them on the page’.
Do you mean Drag’n’Drop them onto the aspx page? If you did that, you have to copies of each one — one set created by the page, and a second created by you which replace the first set.
How do the number of checkboxes vary (’20 (+/- 10)’)? Are they options coming from a database? Are they fixed, but you just don’t know how many yet?
One funkey aspect of ControlCollection, is that a control can only be in one at a time. If you were to try:
It will be added to coll, but it will automatically be removed from Page.Controls.
EDITED: (responding to comment) On your codebehind, create the Checkboxes manually (It’s been a while since I wrote WebForm code, so I’m voguing a bit here), and place the in an array (an array shouldn’t have the problem I mentioned about ControlCollection)
Now for the ‘do stuff here’, we need to get them in the right place. There are a number of ways. We can build a
<table>around them; we can have<asp:placeholder>controls in the aspx which we add them too; we can set the CSS style position attributes.