Sorting Public Albums

Last post 07-08-2009 4:45 PM by Krishna_Sridharan. 5 replies.

Sort Posts:

  • Sorting Public Albums

    07-08-2009, 12:53 PM
    • Member
      3 point Member
    • eric02190
    • Member since 04-02-2009, 1:56 AM
    • Posts 8

     Does anyone know if you can sort the Albums.aspx by newest added by default? Currently when I add a new album it appends to the bottom of the screen. I would like the last added album to be the first one on the screen.

    Thanks!

  • Re: Sorting Public Albums

    07-08-2009, 1:30 PM

    If your images/image name is coming from the database,  You can use order by in your "select" query to sort it.

    Better if you have a column in table storing the record date, you can probably sort it using record date with descending order.


    "select image from table order by desc" and bind it to the control you are using to display it.

    Thanks and Regards

    Krish

    -I have not failed. I've just found 10,000 ways that won't work ! - Edison

    ASP.Net Forums Tips and Guidelines
  • Re: Sorting Public Albums

    07-08-2009, 3:42 PM
    • Member
      3 point Member
    • eric02190
    • Member since 04-02-2009, 1:56 AM
    • Posts 8

    I'm not sure if this is correct or not, but would this stored proc be what is pulling the albums? If so can it be modified to sort the [Albums].[AlbumID] field in DESC order??

     ALTER PROCEDURE GetAlbums

    @IsPublic bit

    AS

    SELECT

    [Albums].[AlbumID],

    [Albums].[Caption],

    [Albums].[IsPublic],

    Count([Photos].[PhotoID]) AS NumberOfPhotos

    FROM [Albums] LEFT JOIN [Photos]

    ON [Albums].[AlbumID] = [Photos].[AlbumID]

    WHERE

    ([Albums].[IsPublic] = @IsPublic OR [Albums].[IsPublic] = 1)

    GROUP BY

    [Albums].[AlbumID],

    [Albums].[Caption],

    [Albums].[IsPublic]

    RETURN

  • Re: Sorting Public Albums

    07-08-2009, 3:54 PM

    Yes certainly. But make sure that the Album Id is getting incremented on every record insertion.

    Thanks and Regards

    Krish

    -I have not failed. I've just found 10,000 ways that won't work ! - Edison

    ASP.Net Forums Tips and Guidelines
  • Re: Sorting Public Albums

    07-08-2009, 4:15 PM
    • Member
      3 point Member
    • eric02190
    • Member since 04-02-2009, 1:56 AM
    • Posts 8

     It does get incremented every time a album gets added. My question is how do I change the code below to return in DESC order?

    ALTER PROCEDURE GetAlbums

    @IsPublic bit

    AS

    SELECT

    [Albums].[AlbumID],

    [Albums].[Caption],

    [Albums].[IsPublic],

    Count([Photos].[PhotoID]) AS NumberOfPhotos

    FROM [Albums] LEFT JOIN [Photos]

    ON [Albums].[AlbumID] = [Photos].[AlbumID]

    WHERE

    ([Albums].[IsPublic] = @IsPublic OR [Albums].[IsPublic] = 1)

    GROUP BY

    [Albums].[AlbumID],

    [Albums].[Caption],

    [Albums].[IsPublic]

    RETURN

  • Re: Sorting Public Albums

    07-08-2009, 4:45 PM
    Answer

    ALTER PROCEDURE GetAlbums

    @IsPublic bit

    AS

    SELECT

    [Albums].[AlbumID],

    [Albums].[Caption],

    [Albums].[IsPublic],

    Count([Photos].[PhotoID]) AS NumberOfPhotos

    FROM [Albums] LEFT JOIN [Photos]

    ON [Albums].[AlbumID] = [Photos].[AlbumID]

    WHERE

    ([Albums].[IsPublic] = @IsPublic OR [Albums].[IsPublic] = 1)

    GROUP BY

    [Albums].[AlbumID],

    [Albums].[Caption],

    [Albums].[IsPublic]

    ORDER BY [Albums].[AlbumID] DESC

    RETURN

    Thanks and Regards

    Krish

    -I have not failed. I've just found 10,000 ways that won't work ! - Edison

    ASP.Net Forums Tips and Guidelines
Page 1 of 1 (6 items)