Sort News Items RRS feed

  • Question

  • User1165899916 posted

    Anybody know how to sort the news items on the news_list.aspx page so that the latest news appears at the top of the page like it does in default.aspx.

    I though of doing it by a sort on the select query but can't seem to find a select query on that page.

    Tuesday, May 8, 2007 5:26 AM

All replies

  • User-2109426844 posted


    This page uses the PagedAnnouncementList stored procedure.  Edit this stored procudure using SQL2005 management studio, and add an order by clause at the end.



    Tuesday, May 8, 2007 6:56 AM
  • User1165899916 posted
    Many thanks, did the trick perfectly.
    Tuesday, May 8, 2007 7:09 AM
  • User1892462997 posted

     PagedAnnouncementList stored procedure

    ORDER BY itemdate ASC, id

    changed to  

     ORDER BY itemdate DESC, id


    The hole procedure:

    ALTER PROCEDURE PagedAnnouncementList
        @pageNum INT = 1,
        @pageSize INT = 10
        DECLARE @rows INT
        DECLARE @keydate DATETIME
        DECLARE @keyid INT
        DECLARE @rowCount FLOAT /* yes we need a float for the math */
        IF @pageNum = 1
                SET @keydate= 0
                SET @keyid=0
                /* get the values for the date and row */
                SELECT @rows = (@pageNum-1) * @pageSize
                SET ROWCOUNT  @rows
                SELECT @keydate=itemdate, @keyid=id FROM announcements ORDER BY itemdate ASC, id ASC 

    SELECT @rowCount=COUNT(*) FROM announcements

    SET  ROWCOUNT @pageSize
        SELECT     id, itemdate, title, description, photo
        FROM         Announcements
        WHERE     (itemdate > @keydate) OR
                              (itemdate = @keydate) AND (id > @keyid)
        ORDER BY itemdate DESC, id
        RETURN CEILING(@rowCount/@pageSize)


    Wednesday, October 10, 2007 1:44 PM
  • User1892462997 posted

    Discard my last comment, that didn't work

    Thursday, October 11, 2007 8:24 PM