0

I have a project where a user needs to loop through approx. 100,000 photos and assign PhotoType ID to each photo.

Project requirement is that only one photo is displayed on screen, so basically it means there would be 100,000 pages holding 1 item.

What would be the best way to start this project and it is obviously that use of ViewState or complete page reload would be waste of resources?

I was thinking of trying to serialize data as a client script variable and then play with it using Page Methods. I am using c# asp.net.

If you have any ideas or a better approach let me know.

mko
  • 6,638
  • 12
  • 67
  • 118
  • So basically it means you'll have one page that can load one of 100,000 items based on something like a querystring variable? – MikeSmithDev Sep 13 '13 at 13:34
  • Or possibly a page that randomly loads an image, any image, that has no PhotoTypeID. – MikeSmithDev Sep 13 '13 at 13:39
  • @MikeSmithDev correct, but I would not do it randomly, because a user could make a mistake and might want to go one step (photo) back – mko Sep 13 '13 at 14:14

2 Answers2

0

For such a big loads of data you need to change the strategy. First of all you can not just load 100k of records to DataSet. You need to do the paging on the server side (and return only required single record from i.e. stored procedure). You don't even need dataset if only one picture is shown per page. In terms of the ViewState - I would disable it completely. You can store the current page in hidden field and use the handlers to show the photo. Also, use AJAX to get the next/previous photos..try to make it as lightweight as possible.

Ivan Sivak
  • 7,178
  • 3
  • 36
  • 42
  • yes but how would you go back and forward if you are pulling only one photo from the db? where is the pager? – mko Sep 14 '13 at 08:25
0

Next and previous buttons would be simple HTML elements with some cool CSS class. Event handlers (when user clicks the next/prev button) would be in JavaScript. The current index (active photo id) can be in hidden field which you will update after each click event (when next is clicked then idx += 1 and idx -= 1 on prev. click). After this you need to retrieve the photo (still in javaScript events) from database. I would suggest WCF or ASMX web services which would return the URL of the http handler (I assume you use handlers to display the varbinary image fields to the html ). Also, before those clicks you can show some nice ajax progress gif animation or so...and the web service itself would call the stored procedure which would return appropriate image from database (based on active index value therefore only 1 needed record). So in the end - you need only: stored procedure, few java script lines of code, handler, web service. No ASP grids or data sets or any need of iterating through the 100k of records. This would be a killer for your performance. Hope this helps to point you a right direction.

Ivan Sivak
  • 7,178
  • 3
  • 36
  • 42
  • Your two answers are not two separate solutions, this answer is just going in to implementation more. I would recommend merging the two and deleting one of the answers. There is nothing wrong with giving separate solutions as separate answers, I just feel that you did not give separate solutions here. – Scott Chamberlain Sep 15 '13 at 19:04
  • @ivan.sivak yout assumption that ids are consequent integers is rushed and possibly misleading – mko Sep 15 '13 at 22:11
  • John: I was not referring to the ids, rather to idx (indexes). – Ivan Sivak Sep 16 '13 at 09:35
  • John: I think we both know that it can't be simple photo id. The most important part is in chosen strategy of the solution/problem. If you see my proposal as wrong, then it's fine. I just tried to help. – Ivan Sivak Sep 20 '13 at 08:59