tags:

views:

44

answers:

1

Hi,

Not sure if phrasing this right, seems simple but not sure best way to do it. Basically, I've got a simple database identifying items of clothing. Just ItemID(PK), ItemName and ItemLink(just the name of the jpeg for that item, which I'll use in .net to construct the correct image url for that item).

Client doesnt want anything fancy, just to click up and down and have the page move thru the DB simply displaying next and previous itenms. So in my SQL procedure, I always just want to access the next image in the DB. I can't figure how to do this without adding an extra column that just displays position in the DB, something like just numbering from 1 to whatever (probably about forty or so images). Start out with '1' on the first page load, store that as a session variable (or cookie), and iterate thru that way? Seems like should be something cleaner.

A: 

Depending on how many images your database contains, it would be create an image object with ID, Name and Link.

Then when page loads get all images from database and create a list of image objects.

This way when user clicks next / previous buttons you can just move forward or backward in the list.

Would mean storing a bit extra in memory but only one trip to the database.

If you need a code sample just let me know :)

timothyclifford
i thought about that, but probably going to be about 30-40 images displayed at a fairly decent size, seems like memory wise would be bit much. Instead of pulling a single image out at a time in my procedure, and worrying about selecting correct image there (previous, next etc) , maybe best way it to pull all the items into a datatable, and create a .net method to pull the correct one from the datatable? I can select a previous or next row that way easier than SQL, no?
bradjay
You're not going to be storing the images in memory, only their location correct? DataTable method would work also, pretty much using inbuilt method to do what I suggested. You could also extend your object / DataTable to include a CurrentRecord property which could store item you're currently displaying and use to keep track of which item / row is next and previous
timothyclifford
timothyclifford
perfect, was hoping on right track. Thank you!
bradjay