Repeater

  • Thread starter Thread starter Doug Parker
  • Start date Start date
D

Doug Parker

I'm trying to use the repeater control to create a column-like row of
data, I've searched the net and it doesn't appear to be that easy. Use
this page for reference:

http://www.westmarkadvisors.com/photo_gallery.php (i'm converting this
to .net)

I'm using the repeater to list all of the thumnails below, but i don't
know how to insert a </tr><tr> break in the code.
AlternatingItemTemplate seems to affect every other row, and as you can
see this needs to affect every four rows.

So basically I have four of these:

<td width="25%" valign="middle" align="center" class="img_sub">
<a href="?p=&photo=1"><img
src="orig_images/Church_FrontView_th.gif" border="0" alt=""
class="bdr_white_th"></a><br>Front View
</td>

then i need to add this:

</tr>
<tr>

and then continue with the <td> cells. Can i accomplish this with the
repeater? or do i have to use DataList?

Any help would be greatly appreciated.
 
Hi,

You can use a repeater or a datalist, the difference is that with a repeater
you have to generate your table, like:
<table>
<asp:repeater ..... >
<itemtemplate>
<tr>
<td> YOUR CONTENT HERE </td>
</tr>
</itemtemplate>
</asp:repeater ..... >
</table>


Whether using DataList or DataGrid the control generate the table for you.
 
I think you are looking for a nested repeater.

<repeater>
<tr>
<repeater>
generate you 4 accross
</repeater>
</tr>
</repeater>

it's easy enough to set up a releation in the dataset or whatever you
are using to populate this.
 
OK - so I use a nested repeater, but in reading more about them it
appears that they are used to fill out child records. In your example,
how would I tell the inner repeater to display only 4 of the X number
of records in the set before going to the outer repeater?
 
i have a auto-incrementing id, but i don't see how i could get the
"</tr><tr>" tag in there even with the number. do i literally have to
create a record with a value of "</tr><tr>"?

this seems a little ridiculous to me that you have this little control
over the display of records. i could accomplish this using a stupid
little for loop in php (below) - is it really this difficult to
accomplish in c#?

<?
for ($i=1;$i<image_count;$i++)
{
?>
<td width="25%" valign="middle" align="center" class="img_sub">
<a href="?p=<?page?>&photo=<?i?>"><img
src="<?path?><?photos[$i]['thumb']?>" border="0" alt=""
class="bdr_white_th"></a><br>
<?photos[$i]['sub']?>
</td>
<?
if ($i == $marker)
{
?>
</tr>
<tr>
<?
$marker += $offset;
}
}
?>

</tr>
</table>

<?
}
}
?>
 
Back
Top