Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing recordset between pages 1

Status
Not open for further replies.

apple17

Programmer
Joined
Jul 5, 2005
Messages
46
Location
US
I have a page that lists people and I want to allow the user to resort on name / city / title / etc. (This is classic ASP). I have now stored all my data in a recordset, so that I can sort it properly the first time through.

That works.

Now I want to allow them to click on a column heading to resort. I can determine which column they clicked on, but how do I get the data back. I really don't want to re-query the DB, the retrieval logic isn't trivial. If I store the data in a Session (which I understand is discouraged), how do I get it back into the recordset? Is there a better way.

I can't find any articles about this on the Web, keep wading through all the .NET solutions.

THKS.
 
One method would be to store the data into an array and then use that array to build your display data.
When a row is clicked and you want to re-sort then you can do one of several things.
1. Submit the page to itself and pass the array.
If you go this way here is an article on it:

2. Have your display data within a SPAN or DIV tag. When one of the column heads is clicked rebuild the SPAN with the newly organized data.

I prefer the second method. The page updates without actually reloading the page so it is cleaner on the clients end. You would need client side scripting to accomplish it but can do it with VBScript or Javascript.


Paranoid? ME?? WHO WANTS TO KNOW????
 
i use this method

Code:
<%sub listOrder(page,orderby,title)
  	order = request.querystring("order")
	ascdesc = request.querystring("ascdesc")
	if order ="" then order = session("startOrder")
	if ascdesc ="" then ascdesc = session("startAscDesc")
	pagenew = page
	if instr(page,"?") >0 then
		pagenew = split(page,"?")(0)
		param = "&"&split(page,"?")(1)
	end if
	if order = orderby then 
		if ascdesc="ASC" then
			pic="asc.gif"
			ascdescnew = "DESC"
		else
			pic="desc.gif" 
			ascdescnew = "ASC"
		end if
	else 
		pic="ascdescblank.gif"
	end if
%>
	<a class="listOrder" href="<%=pagenew%>?order=<%=orderby%>&ascdesc=<%=ascdescnew%><%=param%>"><%=title%><img border="0" src="../images/<%=pic%>"></a> 
<%end sub%>
<%function orderStart(startOrder,ad)
  	order = request.querystring("order")
	ascdesc = request.querystring("ascdesc")
	if order ="" then order = startOrder
	if ascdesc ="" then ascdesc = ucase(ad)
	orderStart = " ORDER BY "&order&" "&ascdesc
	session("startOrder") = startOrder
	session("startAscDesc") = ucase(ad)
end function%>

those functions will write the titles and set up the where clause for the recordset

then set up your table headings
Code:
<table><tr>
        <td class="h3ul"><%call listOrder("admin_deleted.asp","ad_make","Make")%></td>
        <td class="h3ul"><%call listOrder("admin_deleted.asp","ad_model","Model")%></td>
        <td class="h3ul"><%call listOrder("admin_deleted.asp","ad_ref","Ref")%></td>
        <td class="h3ul"><%call listOrder("admin_deleted.asp","ad_date_exp","Expires")%></td>
</tr>
then make your recordset
Code:
<%
  	strSQL = "SELECT FROM tbl_ad WHERE"&orderStart("ad_date_added","desc")
set rsListAll = conn.execute(strSQL)

%>
then build the table
Code:
<%if not rsListAll.eof then
do while not rsListAll.eof%>
      <tr> 
        <td><%=rsListAll("ad_make")%></td>
        <td><%=rsListAll("ad_model")%></td>
        <td><%=rsListAll("ad_ref")%></td>
        <td><%=rsListAll("ad_date_exp")%></td>
      </tr>
<%rsListAll.MoveNext
Loop
End if
set rsListAll = nothing%>
</table>

}...the bane of my life!
 
Try doing a google search on "xml data island
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top