www.webdeveloper.com
Results 1 to 12 of 12

Thread: how to show records in more then one pages

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Posts
    73

    Question how to show records in more then one pages

    now here is my problem..it is a bit idiotic but i m just unable to control it...
    let me put my complete situation here first..!

    i have a got a search form, in which dere r altogether 5 fields.. 2 of dem r combo boxex, 2 text boxes and one a group of radio buttons...

    the user inputs any of his choices into the fields, and den hits da search button and upon his selection of choices da desired result is shown from da database. now if he doesnt enter anything at all in da text boxes, neither he selects any of da entries of combo box and also if he selects da first radio button, which is ofcorse selected as default, even den da result is shown i.e all da entries in da database will be shown and dey will not be filtered. only filtered entries wil be shown upon the selection of dese fields else all entries will be shown. now da problem is dere can be many records and i want to display parts of result in each page, i.e only 10 records will be shown on each page.. 1st 10 on 1st page, next 10 on da 2nd page. i have done all dis recordcount coding...but da problem is dat if i click on da next page link den i dont know wat to pass after "?" i know all da fields will be passed which i want to transfer into da next page but da prb is dat if we have an empty field (from textboxes).. den how will i transfer dat?? and also i m collecting da fields wid a request.form method...whereas after passing through a link it is alwayz collected through request.querystring method. if i use request.querystring method den da values from da searching page will not be collected in the page where i want to sort out da result.
    plz guide me...!

  2. #2
    Join Date
    Apr 2006
    Posts
    63
    Sorry, but I had a little trouble following what you were saying above, but I think you should check out the following link. I think it explains how to do what you are wanting to do.

    http://www.asp101.com/samples/db_pag...age=2&order=id

    Hope that helps,
    Sean

  3. #3
    Join Date
    Aug 2005
    Location
    Karachi, Pakistan
    Posts
    55
    Just study the PageCount, PageSize and AbsolutePage properties of Recordset object and apply a little logic, you will get the solution.

  4. #4
    Join Date
    Apr 2006
    Posts
    73

    ???

    is dere anyone who can help me??
    shud i explain my problem again??

  5. #5
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607
    Here is a link to many web sites that have samples about paging the recordset.

    http://www.google.com/search?hl=en&l...asp+ado+paging

  6. #6
    Join Date
    Apr 2006
    Posts
    73

    ??

    welll...
    i want to ask..can i use session variables?? and if i use den do i have to transfer dese values in link after "?"

  7. #7
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607
    If you use session variables there is no need to pass them in the query string.
    Your able to access them on any page.
    Code:
    response.write Session("ValueName")
    But for what ever reason if you want to pass them in the query string then
    Code:
    Response.redirect "index.asp?Id=" & session("Value1") & "&TC=" & session("Value2") & "&DB=" & session("Value3")
    and going back to what you want. If you just use the ado recordset paging then you acutally do everything on the same page and there is no reason to
    keep going to the next page to view the records. This can all be done in 1 page.
    Last edited by lmf232s; 06-01-2006 at 08:54 AM.

  8. #8
    Join Date
    Apr 2006
    Posts
    73
    and going back to what you want. If you just use the ado recordset paging then you acutally do everything on the same page and there is no reason to
    keep going to the next page to view the records. This can all be done in 1 page.


    i know dis...but u need to transfer da values after "?"..so if i use session variables den i dont need to transfer rite? i only needed to transfer da current page no. rite??

  9. #9
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607
    so if i use session variables den i dont need to transfer rite?
    That is correct, as you can access that value just by referenceing it
    Session("ValueName")

    i only needed to transfer da current page no. rite??
    Not sure what you mean but read on i think i might explain this below.

    i might of misread the post. It looks like your going to use the paging of the record set but if you select a record, how you do pass the values of the selected record to the next page?

    If this is correct, then what you might want to do is for 1 of the fields that you are displaying (I usually make it the first value of the column) make that field a hyper link. When you are building they hyper link you will create the code for query string. Then all you have to do is click on the record you want and that will post the data in the query string when the page is submitted.

    Now what i would do is only pass the value through the query string that will allow you to do a database look up on the next screen instead of passing all the values through the query string.
    Code:
    Response.write "<a href=""NextPage.asp?id=" & oRS1("KeyId") & """>" & oRS1("KeyId") & "</a>"
    And you dont need to show the KeyId of the record but you would need to either add it to the query string that you are building or a combination of fields that you can use to easily look the data up on the next screen.

    Now when i click on this link it will take me to NextPage.asp where i can get this value and do a db look up for the rest of the data.
    Code:
    Dim Id : Id = Request.Querystring("Id")
    SELECT * FROM TABLE WHERE FIELD = '" & ID & "'"
    Am I close?

  10. #10
    Join Date
    Apr 2006
    Posts
    73

    Arrow details...>>>>

    I dont want to transfer any details of a particular record to the next page. I'll explain what i really want to do>>

    Here is my first page (Search.asp) >>>

    2 text boxes
    2 combo boxes
    1 group of radio buttons
    A search button

    now lets assume dat on hitting the "Search" button, the values entered in any of the fields of "Search.asp" will be collected in the next page via request.form method. Now what user can really do is that he can either enter any text in any of the text boxes, select any entry from any of the 2 combo boxes(by default 1st entry is selected), select any of the radio button (by default 1st radio button is selected) and when he hits the "Search" button, the result should be shown on the next page upon the search criteria user has defined. Now a user can enter anything or nothing in the text boxes, select any or leave it to default(i.e 1st entry) from the combo boxes, select any of the radio buttons or just leave it to default (i.e 1st radio button), he can still gets the result if he hits the "Search" button. Now if a user leaves everything as it is, even then he will get the results, and those will be the complete records which exist in the database. Or if he enter anything then according to that criteria, results will be shown.
    I have used a hell lot of if else statements, each having different queries. These if else statements are all based on the user defined entries (i.e different combinations of fields of Search.asp). Now lets assume, upon hitting the "Search" button the page on which the values will be collected is named as "ShowResults.asp". On this page every field of "Search.asp" will be collected by request.form method. I have checked by "len" function to check that if anything is actually entered in the text fields or not. If "len" function returns value < 1 then it means nothing is entered and hence check the combo boxes and radio buttons value, and by different combinations of if else statments the results will be shown. Now the problem is that I want to show these records in a set of 10 on each page. Now if I want to transfer the values collected from "Search.asp" to the same page("ShowResults.asp") again by using "first, previous, next, last" links then how will I know that the values of textboxes exist i.e a user may or may not enter anything in these textboxes. I want to know because I have to pass these values as variables after "?" in each of the links ("first, previous, next, last"). And even if I am able to pass it somehow then the only way to collect these values in the same page is by request.querystring method, whereas I have used request.form method by collecting the values, because on the first place these values are actually coming from the "Search.asp" page. And the method I have used is "post" on "Search.asp". I tried with "get" method and then changed request.form method to request.querystring but it did not work.
    One of my friends advised me to use session variables in collecting these values on the first place, hene I will not be required to pass these values as variables in each link("first, previous, next, last"). But will it work?? Will session variables be able to show the remaining part of records??

    Am I clear enough?

  11. #11
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607
    omarr,
    You are coming in loud and clear and i do seem to understand the problem a little better.

    Yes you can do this with session variables and it will work. But IMO i do not like using session variables for anything else than settings for users once they log in or that type of data. Im not a fan of using sessions for random data. Depending on who you talk to that could go either way.

    Any way, im on my way out the door so i dont have much time.
    What would currently work for you (I think) is to create some hidden fields on the ShowResults.asp page and store the values of search.asp in them. Then all you have to do is a response.form("hidtxt?") to get that value again.

    Although something else that you can do is this.

    When you first request the query string values, store them in variables.
    Then for the first, next, last, previous links, append those values to those links so that when 1 is clicked it will repost those values.

    A quick example
    Dim txtMyText : txtMyText = Request.form("Field from Search.asp")

    When building the links just add this in there. Use the same querystring
    Code:
    <a href="SearchResults.asp?Id=<%=txtMyText%>&Id2=<%=?%>">First</a>
    or 
    Response.write "<a href=""ShowResults.asp?Id=" & txtMyText & "&Id2=" & SOmeField & """>First</a>
    Although you will have to have a variable to get it from the querystring after that.

    Does that help?

    Post back and let me know. I took the day off tomorrow but you know i cant stay away from the computer for too long.
    Last edited by lmf232s; 06-01-2006 at 05:10 PM.

  12. #12
    Join Date
    Apr 2006
    Posts
    73

    ok..

    What would currently work for you (I think) is to create some hidden fields on the ShowResults.asp page and store the values of search.asp in them. Then all you have to do is a response.form("hidtxt?") to get that value again

    i'll try dis out...

    but den i wont need to transfer dese values after "?"...rite??



    When you first request the query string values, store them in variables.
    Then for the first, next, last, previous links, append those values to those links so that when 1 is clicked it will repost those values.

    A quick example
    Dim txtMyText : txtMyText = Request.form("Field from Search.asp")

    When building the links just add this in there. Use the same querystring

    Code:

    <a href="SearchResults.asp?Id=<%=txtMyText%>&Id2=<%=?%>">First</a>
    or
    Response.write "<a href=""ShowResults.asp?Id=" & txtMyText & "&Id2=" & SOmeField & """>First</a>

    Although you will have to have a variable to get it from the querystring after that.


    i tried dis..but da prb is dat i firstly collected dese values via request.form method and den i will need to collect it via request.querystring method, which does not work...!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles