Identifying last item in a Repeater

J

JesperGJensen

I am using a Repeater to build a Table.

<asp:Repeater ID="rptComplaintReasons" runat="server">
<HeaderTemplate>
<table style="border: solid 1px black;">
</HeaderTemplate>

<ItemTemplate>
<tr>
<td style="border-right: dotted 1px black; border-
bottom: dotted 1px black;">
cell 1
</td>
<td style="border-bottom: dotted 1px black; padding-
top: 3px;">
cell 2
</td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

The whole table has a black solid border and the inner cells are
divided by a dotted black border.
Unfortunately both the dotted border and the solid border is visible
at the bottom of the last row of cells.

I would like to identify this last row and use a CSS class that only
does a right border there. This would remove the last dotted bottom
border for me.

Anyone have any advice?
 
C

Coskun SUNALI [MVP]

Hi Jesper,

You can use the following code as a starting point.

protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
if (e.Item.ItemIndex == Repeater1.Items.Count - 1)
{
// you can find any control inside the last row using
e.Item.FindControl and set its style or CSS properties
}
}
}

--
All the best,
Coskun SUNALI
MVP ASP/ASP.NET
http://sunali.com
http://www.propeople.dk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,114
Latest member
GlucoPremiumReview
Top