asp pagination help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tarakaram
    New Member
    • Aug 2005
    • 1

    asp pagination help

    hello friends
    I am facing with this pagination problem for few days. i desperately looking for solution any advice or help will be highly appreciated.
    my code will be generating the records into the table i had placed hyperlinks so that based on the number he clciked the page will be generated. this is working fine but the main thing. if he check a checkbox and go to next page and check another record i am losing the previous checked record.
    thank you
    ram
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    #2
    maintain the checked value in session and try again

    Comment

    • xeilok
      New Member
      • Jul 2007
      • 1

      #3
      Originally posted by tarakaram
      hello friends
      I am facing with this pagination problem for few days. i desperately looking for solution any advice or help will be highly appreciated.
      my code will be generating the records into the table i had placed hyperlinks so that based on the number he clciked the page will be generated. this is working fine but the main thing. if he check a checkbox and go to next page and check another record i am losing the previous checked record.
      thank you
      ram
      Hey I came across this in trying to find a solution to the same issue, then went back and came up with another solution that handled 'pagination' on the client side rather than with asp. I am a newbie to all programming, so my solution may not be great for larger record sets.

      Instead of letting ASP resubmit the page back and forth, i display ALL the record set fields on the page, then show and hide appropriate tables (with CSS, Javascript and HTML DOM styles) according to the link the user clicks. i.e. if link one is clicked, show table one ONLY, if link two is clicked show table two ONLY etc. I will paste my code i hope this helps you can email me at xeilok@gmail.co m if you have any questions or suggestions. Thanks.


      there arent many comments in my code but since i use only basic routines im sure you can understand it, if not please email me.



      <%@language=vbs cript%>
      <%option explicit%>
      <!-- this include holds the database connection, please change to suit urs-->
      <!--#include file="../../includes/functions/db_functions.as p" -->
      <%
      dim k
      function displayColleagu es()
      Dim objRS, strSQL, x, j, i
      Set objRS=Server.Cr eateObject("ADO DB.Recordset")

      strSQL = "select first_name, last_name, email from profile " &_
      "order by last_name"
      If Not (DB_Connect) Then 'my db connection function
      response.Write ("An error occured: " & err.description )
      End If

      set objRS = cnnGT.Execute(s trSQL)
      if err.number <> 0 then
      response.Write ("An error occured: " & err.description )
      end if

      if objRS.EOF and objRS.BOF then
      response.Write ("<table><tr><t d colspan=""3"" align=""center" ">No Records Found!</td></tr></table>")
      else
      j = 0 ' counts upto page size
      k = 1 ' counts number of tables
      do until objRS.EOF

      if (j = 0) then 'write new table
      Response.Write( "<table border=""1"" width=""100%"" id=""colleagueT able" & k & """ style=""display :none;"">" & vbcrlf)
      end if

      Response.Write( "<tr>" & vbcrlf)
      response.write( "<td><input type=""checkbox "" name=""raters"" id=""raters"" /></td>" & vbcrlf)
      for each x in objRS.fields
      if (x.name <> "email") then 'not displaying email
      response.write( "<td class=""text""> " & x.value & "</td>" & vbcrlf)
      end if
      next
      Response.Write( "</tr>" & vbcrlf)

      j = j + 1

      if (j = 10) then ' j=10 is the hardcoded page size
      response.Write "</table>"
      j = 0
      k = k + 1
      end if

      objRS.MoveNext
      loop
      response.Write ("<table border=""1"" width=""100%""> <tr><td colspan=""3"" align=""center" ">" & vbcrlf)

      for i = 1 to k 'write the links to the tables
      response.Write ("<a href=""#"" name=""" & i & """ id = """ & i & """ onclick=""displ ay(" & i & ");"">" & i & "</a>")
      next

      'holds table count
      response.Write ("<input type=""hidden"" name=""tableCou nt"" id=""tableCount "" value=""" & k & """ />")
      response.Write ("</td></tr></table>" & vbcrlf)

      end if
      end function
      %>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head>
      <link rel="stylesheet " type="text/css" media="screen" href="../../includes/goaltracker.css ">
      <title>Select Raters</title>
      <style type="text/css">
      #wrapper {
      width: 600px;
      margin: 0px auto;
      }
      #colleagueTable td { font-family: Arial, Helvetica, sans-serif; font-size: 12px;}
      td.text {width:50%;}
      .header {font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
      .blueBack{
      background-color:#003399;
      text-align:center;
      color:#ffffff;
      font-weight: bold;
      font-size: 18px;
      font-family: Arial, Helvetica, sans-serif;
      }
      hr.thick {
      height:10px;
      background-color:#003399;
      }
      hr.thin {
      width:99%;
      }
      a {
      padding: 0 0 0 5px;
      }
      </style>
      <script type="text/javascript">
      function checkRaters(frm Obj){
      var count = 0;
      for (var i=0; i < frmObj.raters.l ength; i++){
      if (frmObj.raters[i].checked){
      count++;
      }
      }
      if((count<=0) || (count>7)){
      alert ("You have selected " + count + " raters. PLease select between 1 and 7 raters");
      return false;
      }
      }



      function display(id){ //id = table id
      // JAVASCRIPT THAT SHOWS AND HIDES THE TABLES
      var tableCount = "";
      tableCount = document.getEle mentById("table Count").value;
      for (var i=1; i<=tableCount; i++){ //first hide all tables
      document.getEle mentById("colle agueTable" + i).style.displa y = "none";
      }
      // then show the table you want
      document.getEle mentById("colle agueTable" + id).style.displ ay = "block";
      }
      </script>
      </head>
      <body onload="display (1);"> <!--Onload displays first table-->
      <!--#include file="../../includes/header.asp" -->
      <div id="wrapper">
      <form id="frm" method="post" onsubmit="retur n checkRaters(thi s);" action="process _raters.asp">
      <table width="100%" border="0" cellpadding="0" cellspacing="5" id="colleagueTa ble">
      <tr>
      <td colspan="3" align="right">< %=date()%></td>
      </tr>
      <tr>
      <td colspan="3" class="blueBack ">Please Select Your Raters From The List Below:</td>
      </tr>
      <tr>
      <td class="header"> &nbsp;&nbsp; </td>
      <td class="header"> First Name</td>
      <td class="header"> Last Name</td>
      </tr>
      <tr>
      <td colspan="3">
      <%displayCollea gues()%>
      </td>
      </tr>
      <tr>
      <td colspan="3" align="right">< input type="submit" value="Select Raters" /></td>
      </tr>
      </table>
      </form>
      </div>
      </body>
      </html>

      Comment

      Working...