Kirschstein
Kirschstein

Reputation: 14868

ASP.NET Generate a table from list with dynamic number of rows and columns

I have a list of items which I want the user to be able to tick which are appropriate to them.

Currently I have a <ul> generated by a Repeater with checkbox and label controls placed in side, all working fine.

However, the <ul> is taking up too much space on the screen and I need to condense it. I think the best approach would be a table that expands based on the number of items, 9 resultining a 3x3 grid, 12 a 3x4 grid, 16 a 4x4 grid etc up to a maximum width of 6 rows.

Any suggestions for where to start?

Upvotes: 0

Views: 861

Answers (3)

BBlake
BBlake

Reputation: 2398

The approach I would take would be a combination of the CheckBoxList to control number of columns and rows, then use CSS to control how that is displayed in the browser. I've always found the default formatting of the CBL to put way too much padding between the various checkboxes. That way you can find the best fit to get the most information in the browser window.

Upvotes: 0

Jamie Ide
Jamie Ide

Reputation: 49251

I think you can achieve this by using a CheckBoxList control. It has a RepeatColumns property that can be used to specify the number of columns.

Upvotes: 1

Matthew Dresser
Matthew Dresser

Reputation: 11442

Use an asp.net CheckBoxList control.

You can control the way it displays e.g. the number of rows/columns it uses.

Upvotes: 2

Related Questions