I could not find an answer for my question but I think you can help me 🙂
I have a repeater in an ASP.NET website that I want to only show the 3 newest entries. I know it’s possible but I can’t get it to work.. 🙁
My repeater looks like this
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="Sql_letter">
<ItemTemplate>
<p><%# Eval("Wishlist_Letter_FirstName") %> fra <%# Eval("Wishlist_Letter_City") %></p>
<p>Har skrevet til Julemanden</p>
<asp:TextBox ID="r" runat="server" Text='<%# Eval("Wishlist_Letter_Message")%>' TextMode="MultiLine" CssClass="txt_message" BackColor="Transparent" BorderWidth="0" BorderStyle="None" ReadOnly="True"></asp:TextBox>
<br /> <br />
</ItemTemplate>
</asp:Repeater>
And my SqlDataSource:
<asp:SqlDataSource ID="Sql_letter" runat="server"
ConnectionString="<%$ ConnectionStrings:sqlconnection %>"
SelectCommand="SELECT * FROM [Wishlist_Letter]">
</asp:SqlDataSource>
The
SelectCommandshould be something likebut you need to have a
Timestampfield or something equal on your table. There is no natural ordering on ms sql which guarantees to return the latest three entries.In your case it should be