Monthly Repeater for news articles

Discussion in 'ASP .Net' started by anthonykallay, Apr 23, 2007.

  1. Hi,

    I am trying to display my news articles by month, i am aproaching this
    via the use of a nested repeater so that the main rptr will display
    the month abnd then using itemdatabound i can pull all articles for
    that month.. What i am struggling with is the code to programatically
    fill the main repeater with months automatically, any help to achieve
    this would be greatly appreciated..

    eg:

    April 2007
    news1
    news2
    news3
    March 2007
    news1
    news2
    news3
    Feb 2007
    news1
    news2
    news3
    Jan 2007
    news1
    news2
    news3
    Dec 2006
    news1
    news2
    news3

    Cheers Anthony
     
    anthonykallay, Apr 23, 2007
    #1
    1. Advertisements

  2. anthonykallay

    Ray Costanzo Guest

    Where are you getting your list of months? Are you just picking a date, say
    January of 2006, and doing every month since then? Or do you have some data
    source that has news articles, and you want to display each month for which
    there is a news article?

    Ray at work
     
    Ray Costanzo, Apr 23, 2007
    #2
    1. Advertisements

  3. anthonykallay

    sloan Guest

    sloan, Apr 23, 2007
    #3
  4. anthonykallay

    sloan Guest

    Here's a query for you, using the Northwind database.

    You can easily adjust it for news articles.


    Select OrderID , OrderDate , datepart(yyyy , OrderDate) as OrderYear ,
    datepart(m , OrderDate) as OrderMonth from Orders


    WHERE
    DATEDIFF ( yyyy , OrderDate , '1/1/1999' ) <=2

    ORDER BY
    datepart(yyyy , OrderDate) DESC , datepart(m , OrderDate) DESC
     
    sloan, Apr 23, 2007
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.