473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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
Aug 19 '05 #1
2 2948
nirmalsingh
218 100+
maintain the checked value in session and try again
Jan 8 '07 #2
xeilok
1
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.com 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=vbscript%>
<%option explicit%>
<!-- this include holds the database connection, please change to suit urs-->
<!--#include file="../../includes/functions/db_functions.asp" -->
<%
dim k
function displayColleagues()
Dim objRS, strSQL, x, j, i
Set objRS=Server.CreateObject("ADODB.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(strSQL)
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><td 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=""colleagueTable" & 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=""display(" & i & ");"">" & i & "</a>")
next

'holds table count
response.Write ("<input type=""hidden"" name=""tableCount"" 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.dtd">
<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(frmObj){
var count = 0;
for (var i=0; i < frmObj.raters.length; 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.getElementById("tableCount").value;
for (var i=1; i<=tableCount; i++){ //first hide all tables
document.getElementById("colleagueTable" + i).style.display = "none";
}
// then show the table you want
document.getElementById("colleagueTable" + id).style.display = "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="return checkRaters(this);" action="process_raters.asp">
<table width="100%" border="0" cellpadding="0" cellspacing="5" id="colleagueTable">
<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">
<%displayColleagues()%>
</td>
</tr>
<tr>
<td colspan="3" align="right"><input type="submit" value="Select Raters" /></td>
</tr>
</table>
</form>
</div>
</body>
</html>
Jul 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Faree | last post by:
I am workign on a news portal which needs paginaiton as usual.but all the code i got depends on the number of records that will come from database :( .it is working well too. But i need...
11
by: ste | last post by:
Hi there, Further to my recent posts where I've received excellent help from Rik and Jerry, I've ended up with an image gallery on my website that displays images in a table, 3 images per row. ...
1
by: dhanu | last post by:
How to manage pagination in AJAX? My requirement is similar to GMails inbox feature. Whenever a new mail comes in,the newly arrived mail is at the start of my inbox and last row in that page...
1
by: OceanBreeze | last post by:
I am new to .Net. I am using ASP 2.0 and C#. I want to pupolate a data grid programatically using the values obtained from a list conating domain objects. E.g., DAL.GetEmployee() returns a...
0
by: OceanBreeze | last post by:
I am using C# Page_Laod function to populate a web page with a table populated with several records. The table, rows (containing values) are popuated programatically with the values obtained from...
1
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that...
16
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) ...
4
by: ArizonaJohn | last post by:
Hello, The code below works great. The user enters a name into an HTML form, the code looks up a table with that name, and then that table is displayed. I am trying to use pagination with it,...
2
by: kkshansid | last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.