Kevin
Kevin

Reputation: 1950

Looping data with a Repeater

For an example of what I'm attempting to accomplish, see below. I need to loop through a data source, displaying a value from every datarow in its own tablecell. (table is 3 columns wide)

Normally I'd use a modulus in the code behind to determine if a table row should be ended and a new row started. But I swear I recall reading that the Repeater control has this capability built in.

Pseudocode/table:

Header: <table>
<tr><td>Bind("ProductID")</td><td>Bind("ProductID")</td><td>Bind("ProductID")</td></tr>
Footer: </table>

A simple example of the output is:

1 2 3 
4 5 6
7 8 9

So what I'm wondering is there a "built in" way to accomplish this, or should I proceed with a mod check in the code behind.

Thanks Kevin

Upvotes: 1

Views: 132

Answers (2)

veggerby
veggerby

Reputation: 9020

The Repeater does not have it the ListView however does.

Edit I was actually thinking of the DataList (new name for the "old" ListView") as Canavar mentions, but the new ListView is so flexible I'd bet you can use it as well.

Upvotes: 2

Canavar
Canavar

Reputation: 48108

You can use DataList's RepeatColumns property.

Upvotes: 2

Related Questions