Iâm a newcomer to ASP.NET (3 months) so am unsure how to solve this problemâ¦
I run a village website which has about 60 advertisers. The details of the advertisers are held in the SQL Server database that holds other information about the site.
One of the pages shows all 60+ adverts in a gallery, using an ASP.NET ListView control.
To avoid any advertiser being âtop of the listâ, the sequence of adverts is deliberately randomised on every visit using âORDER BY NEWID()â in the SQL retrieval statement.
Iâd like to reduce this long page to show only 6 at a time, with buttons to navigate back and forth, and have done this with a DataPager control and AJAX to minimise flicker (pages 544-549 of Imar's Beginning ASP.Net 4.5 book)
However, when I page back and forth the pages show different content each time. Clearly the ârandomiseâ effect is being called on every load/postback of the page.
Though Iâm savvy enough to, say, write a stored procedure to generate a separate randomised SQL table on a scheduled basis and using that instead, it seems like a sledgehammer to crack a nut.
Iâm guessing there must be some way of retrieving the 60+ records (4 brief text fields each) then storing them in a randomised way âlocalâ to the user, so that paging back and forth maintains the sequence.
Despite trawling the web, Iâve not come across anything that has helped. Paging- yes, randomising â yes. But not both together.
Either thereâs something simple and obvious Iâm missing, or this truly is a tricky puzzle.
Iâm not looking for someone to write the code/markup for me, simply to suggest what approach is needed and, perhaps, where I might find reference material to help me put the code together.
The software/architecture I use includes MS Expression Studio 4 Web Professional, Visual Studio Express 2012 for Web, SQL Server 2008 and ASP.NET 4.5 with VB