Last post Jul 07, 2011 12:38 PM by L.A.M.
Jul 05, 2011 10:55 PM|L.A.M.|LINK
(I'm still newbie in some .net pieces and ADO is one of them, so any help will be appreciated)
I'm retrieving a record from a mdb file based on its ID (with some WHERE and ORDER BY clauses) and displaying it but I need to get the ID from previous and next record, if they exist, so I can build a "next" and "previous" link in the page.
I've been googling for some time now and can't find a decent direction or example! What's the best aproach? Datagrid?
Thanks in advance.
Jul 06, 2011 04:11 AM|luappy13|LINK
ListView/GridView has paging (id go with ListView as it is far more flexible + uses DataPager which can use the querystring for search engines to be able to crawl your indexes)
Jul 06, 2011 11:20 AM|L.A.M.|LINK
As I told, I haven't yet fully understand the fundamentals of this part of .net and all I need right now is something that I could easily do in classic ASP ;)
I have a page with a list of records ordered with some criteria that provide a link to a individual detail page based on its ID (which is unique but not sequencial - detailpage.aspx?id=12345). Now, when I see the record in this detail page I need to have
a next and previous link also based on the ID - like:
"previous" -> detailpage.aspx?id=45454
"next" -> detailpage.aspx?id=09989
the data looks something like this:
ID TITLE DESCR
45454 Title X Blah blah...
12345 Title Y Blah blah...
09989 Title Z Blah...
The database isn't very long but it seems so inadequate to use some methods I've seen of populating dataadapter + dataset and then looping through the row to find currentID + next + previous! Isn't there a simpler method like move.next / move.previous?
Do you know any documentation or example that I can study from?
Jul 07, 2011 01:25 AM|L.A.M.|LINK
I'm now trying to solve the problem with ListView... but still can't make what I need and didn't found any proper documentation except for the basic paging with DataPager which is too "static" - next, previous, first and last page! Com'on MS... you can do
better than that.
Anyway, thank you for your answer luappy13.
Jul 07, 2011 04:16 AM|luappy13|LINK
If you set the datapager PageSize to one in the details view page (with a listview as the databound control) AND the order of the records is as you want to page them i.e. id 1234, 4096, 8192 and you want IF @ pageId 4096 PREV = 1234 AND NEXT = 8192 then
the paging will work as you want (add the QueryStringParameter to the datapager to get a querystring i.e. ?pid=4096).
If your records are not in order then you need to create a form of heirachical data structure that allows you to know prev/next
Post code and I'll see if I can knock up a sample for you
Jul 07, 2011 12:38 PM|L.A.M.|LINK
Well I got myself to the pagesize=1 and it has an order but I'm stuck in a solution to go directly to a specific page where the item ID (from the db field) matches a queryString("ID") and still maintain the previous and next buttons - like for example a
direct link listview.aspx?work=1234 which is @ page 12 and start displaying @ page 12 with prev / next buttons but if no query string just a normal display @ page 0
Here is the code sample (just a work in progress to see if I can make it work as needed)
Thank you for your good will.
Dim conn =
Data Source=" + Server.MapPath("~/_db/database.mdb")
Dim workID = Request.QueryString("work")
Dim sql =
ID, titulo, descrPT, img0 FROM works WHERE onoff='1' AND display='1' ORDER BY wrkdate DESC, hier DESC"
worksDataSource.ConnectionString = conn
worksDataSource.SelectCommand = sql
XHTML 1.0 Transitional//EN"
"~/_images/_works/" & Eval("img0") %>'
"listview.aspx?work=" & Eval("ID") %>'