Skip to main content
Known Participant
November 16, 2010
Answered

First Record in a Repeat Region

  • November 16, 2010
  • 1 reply
  • 694 views

I have a Repeat Region on my page showing all records from a Recordset. My recordset has a SORT by Date DESC in it, so that the most recent record is displayed first on the page.

I would like to add a static Text next to the first record only.

In other words, let's say I have a list of Name:

Joe

Frank

Mark

Laura

Linda

I'd like to display "Winner" next to the first record only, in this case Joe:

Joe [Winner]

Frank

Mark

Laura

Linda

This topic has been closed for replies.
Correct answer bregent

You've got a recordcounter already defined so use that:

<td width="33%" class="borderrightbottom"  style="vertical-align:top"><%=(rsShippingAddress.Fields.Item("Address   1").Value)%> <%=(rsShippingAddress.Fields.Item("Address2").Value)%>

<% If recordcounter = 1 Then %>

     [Winner]

<% End If %>

<br  />

or alternatively

<%

If recordcounter = 1 Then

     response.write " [Winner]"

End If

%>

1 reply

November 16, 2010

You don't mention what language you're using and there's no code provided so I can't provide an example, but basically insert a conditional region in your loop where if the current row = 1 then highlight the output else perform normal styling.

BracholeAuthor
Known Participant
November 16, 2010

sorry about that...I'm using ASP VNScript and here's my script:

<table width="100%" border="0" cellpadding="5" cellspacing="0">
            <tr style="background-color:#EEEEEE; text-align:left; font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:14px">
              <td bgcolor="#90AFCD" class="borderbottom"><strong>Shipping Addresses</strong></td>
              <td bgcolor="#90AFCD" class="borderbottom"> </td>
              <td bgcolor="#90AFCD" class="borderbottom" style="text-align:right"><a href="addressesship.asp" class="Link">Add a new Shipping Address</a></td>
            </tr>
            <%
While ((Repeat1__numRows <> 0) AND (NOT rsShippingAddress.EOF))
%>
  <tr style="vertical-align:middle; text-align:left; font-family:Arial, Helvetica, sans-serif; font-size:12px" <%
RecordCounter = RecordCounter + 1
If RecordCounter Mod 2 = 1 Then
  Response.Write "bgcolor='#f1f1f1'"
End If
%>>
    <td width="40%" height="45" class="borderrightbottomleft" style="vertical-align:top; color:#666">Date added: <%= DoDateTime((rsShippingAddress.Fields.Item("DateAdded").Value), 2, 2070) %></td>
    <td width="33%" class="borderrightbottom" style="vertical-align:top"><%=(rsShippingAddress.Fields.Item("Address1").Value)%> <%=(rsShippingAddress.Fields.Item("Address2").Value)%><br />
      <%=(rsShippingAddress.Fields.Item("City").Value)%> <%=(rsShippingAddress.Fields.Item("Province").Value)%> <%=(rsShippingAddress.Fields.Item("PostalCode1").Value)%> <%=(rsShippingAddress.Fields.Item("PostalCode2").Value)%></td>
    <td width="27%" class="borderrightbottom" style="vertical-align:top; text-align:right; word-spacing:5px"><img src="/images/icons/edit.png" alt="Change E-Mail" width="16" height="16" border="0" style="vertical-align:bottom"/><a href="/en/calcenter/account/addressesship_edit.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "id=" & rsShippingAddress.Fields.Item("id").Value %>">Change</a></td>
  </tr>
  <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsShippingAddress.MoveNext()
Wend
%>
          </table>

bregentCorrect answer
Participating Frequently
November 16, 2010

You've got a recordcounter already defined so use that:

<td width="33%" class="borderrightbottom"  style="vertical-align:top"><%=(rsShippingAddress.Fields.Item("Address   1").Value)%> <%=(rsShippingAddress.Fields.Item("Address2").Value)%>

<% If recordcounter = 1 Then %>

     [Winner]

<% End If %>

<br  />

or alternatively

<%

If recordcounter = 1 Then

     response.write " [Winner]"

End If

%>