views:

897

answers:

5

I know how to use the checkboxlist in ASP.NET to display options retrieved from a database. What I don't know how to do is to make this 2-dimensional. That is, I need a list of checkboxlists where I don't know how long the list is; both dimensions of the checkboxlist will be determined by

list of people (pulled from database) list of tasks (pulled from database)

and the user of the web page will click in column/row to specify which people will be assigned which tasks.

Right now I'm thinking that my only option is to brute-force it by creating a table and populate each cell with its own checkbox. (yuck)

Is there a more elegant way to create a 2-dimensional array of checkboxes with labels for both rows and columns?

+2  A: 

I would use a repeater along with a checkboxlist. Depending on how your database is setup you could have each checkboxlist databound.

Smallinov
A: 

I've done this before and resorted to the brute-force method you suggest.

It's not as nasty as you'd think. Other solutions that were declarative and databound would likely be just as convoluted and confusing.

Ben Scheirman
A: 

You can programmitaclly use a GridView control. It's inherently two-dimensional and you can use databound CheckBoxFields for it.

Mark Cidade
A GridView would be terrible. A Repeater would be good.
lordscarlet
A: 

I use the ASPxGridView from DevExpress. It has a control column type of Selected (or something like that) which will display a checkbox in the column with the other column populated from your bound datasource. The User can select any rows desired by checking the checkbox on the row and you can get all the selected rows easily inot a collection to process. DevExpress components really do get rid of a lot of brute-force programming.

Mike
A: 

If you're looking for a quick and dirty way, you can use the AJAX Control Toolkit with the two controls and can populate one based on the other. If that's not what you're looking for, I'd do it the brute force way.

Jason N. Gaylord