locked
show latest 3 images from picture library in my webpart RRS feed

  • Question

  • Hi,

    I have a picture library to upload images.I want to show the latest 3 images in the picture library inside my custom webpart..

    how can i do this???

    Is there any caml query available?

    pls help

    tanks in advance..


    Root1234

    Wednesday, August 8, 2012 3:19 PM

Answers

  • Hi Sooraj,

    Please change it order by Created descending as following:
    qry.Query = "<OrderBy><FieldRef Name='Created' Ascending='False'/></OrderBy>";

    Thanks,
    Lhan Han

    • Marked as answer by Qiao Wei Sunday, August 19, 2012 12:49 PM
    Thursday, August 16, 2012 7:26 AM

All replies

  • Hey,

    You can acheive it easily using CAML query as u said by firing "retrieve fields based on modified or set RowLimit"you can get the latest uploaded images.

    Refer this thread

    "http://stackoverflow.com/questions/824202/sharepoint-how-to-get-top-5-records-by-using-caml-query-from-a-list"

    Let me know if you have any queries :)


    "The Only Way To Get Smarter Is By Playing A Smarter Opponent"

    Wednesday, August 8, 2012 4:02 PM
  • hi,

    SPQuery qry = new SPQuery();
    qry.Query = "<OrderBy><FieldRef Name='Created' Ascending='True'/></OrderBy>"; ;
    qry.RowLimit = 3

    i used above query to retrieve the latest 3 images from picture library, but i cannot get the latest 3 images

    wats the problem with me?

    pls help?


    Root1234

    • Proposed as answer by HeToC Wednesday, August 8, 2012 4:17 PM
    Wednesday, August 8, 2012 4:14 PM
  • Hi Sooraj,

    Please change it order by Created descending as following:
    qry.Query = "<OrderBy><FieldRef Name='Created' Ascending='False'/></OrderBy>";

    Thanks,
    Lhan Han

    • Marked as answer by Qiao Wei Sunday, August 19, 2012 12:49 PM
    Thursday, August 16, 2012 7:26 AM