|
 |
asp_web_howto thread: paging through a recordset
Message #1 by "Ryan vd Merwe" <ryan@w...> on Tue, 30 Oct 2001 09:58:27
|
|
Hi
how do i page through a recordset, but instead of having numeric links
such as "Go to records: 1-10, 11-20...." I need to have alph links such
as "Go to records: A-G, H-M, N-T....."
it is difficult to explain but i hope someone can supply me with the
answer.
thanks
ryan
Message #2 by Sam Clohesy <sam@e...> on Tue, 30 Oct 2001 11:07:03 -0000
|
|
Like this?
Page called contact.asp
<%
DIM conn,rs,strSQL
If Request.Querystring("letter") = "" Then
sLetter = ""
else
sLetter=Request.QueryString("letter")
end if
strSQL = "SELECT * FROM contacts ORDER BY ContactLastName ASC "
Set rsDisplayName = Server.CreateObject("ADODB.Recordset")
rsDisplayName.Open strSQL, conn,2
sAlphabet="abcdefghijklmnopqrstuvwxyz"
DIM sLetters(26)
For i=1 to 26
sLetters(i)= MID(sAlphabet,i,1)
Next
%>
<b><A class = 'link' HREF="contact.asp?view=1">All</a>|</b><%
For i=1 to 26
Set rsDisplayName = Server.CreateObject("ADODB.Recordset")
rsDisplayName.Open strSQL, conn,2
isLink = false
Do While Not rsDisplayName.Eof
if UCASE(Left(rsDisplayName("ContactLastName"),1)) = UCASE(sLetters(i))
then
isLink = true
Exit Do
end if
rsDisplayName.MoveNext
Loop
rsDisplayName.Close
Set rsDisplayName=Nothing
if isLink = true then %>
<b><A class = 'link'
HREF="contact.asp?view=1&letter=<%=UCASE(sLetters(i))%>"><%=UCASE(sLetters(i
))%></A></b><span class = 'text'>|</span>
<% else %>
<span CLASS="deadlinkdarkfaint"><% response.write UCASE(sLetters(i))
%>
<% if i < 26 then %><span class = 'text'>|</span><% end if %>
</span>
<% end if
next
%>
-----Original Message-----
From: Ryan vd Merwe [mailto:ryan@w...]
Sent: 30 October 2001 09:58
To: ASP Web HowTo
Subject: [asp_web_howto] paging through a recordset
Hi
how do i page through a recordset, but instead of having numeric links
such as "Go to records: 1-10, 11-20...." I need to have alph links such
as "Go to records: A-G, H-M, N-T....."
it is difficult to explain but i hope someone can supply me with the
answer.
thanks
ryan
Message #3 by "Ryan vd Merwe" <ryan@w...> on Tue, 30 Oct 2001 12:43:35
|
|
thanks Sam
but this code does not list the information?
> Like this?
>
> Page called contact.asp
> <%
>
> DIM conn,rs,strSQL
>
> If Request.Querystring("letter") = "" Then
> sLetter = ""
> else
> sLetter=Request.QueryString("letter")
> end if
> strSQL = "SELECT * FROM contacts ORDER BY ContactLastName ASC "
>
>
> Set rsDisplayName = Server.CreateObject("ADODB.Recordset")
> rsDisplayName.Open strSQL, conn,2
>
> sAlphabet="abcdefghijklmnopqrstuvwxyz"
> DIM sLetters(26)
> For i=1 to 26
> sLetters(i)= MID(sAlphabet,i,1)
> Next
> %>
>
> <b><A class = 'link' HREF="contact.asp?view=1">All</a>|</b><%
> For i=1 to 26
> Set rsDisplayName = Server.CreateObject("ADODB.Recordset")
> rsDisplayName.Open strSQL, conn,2
> isLink = false
> Do While Not rsDisplayName.Eof
>
>
> if UCASE(Left(rsDisplayName("ContactLastName"),1)) = UCASE(sLetters
(i))
> then
> isLink = true
> Exit Do
> end if
>
>
>
> rsDisplayName.MoveNext
> Loop
>
> rsDisplayName.Close
> Set rsDisplayName=Nothing
>
> if isLink = true then %>
> <b><A class = 'link'
> HREF="contact.asp?view=1&letter=<%=UCASE(sLetters(i))%>"><%=UCASE
(sLetters(i
> ))%></A></b><span class = 'text'>|</span>
> <% else %>
> <span CLASS="deadlinkdarkfaint"><% response.write UCASE(sLetters
(i))
> %>
> <% if i < 26 then %><span class = 'text'>|</span><% end if %>
> </span>
> <% end if
> next
>
> %>
>
> -----Original Message-----
> From: Ryan vd Merwe [mailto:ryan@w...]
> Sent: 30 October 2001 09:58
> To: ASP Web HowTo
> Subject: [asp_web_howto] paging through a recordset
>
>
> Hi
>
> how do i page through a recordset, but instead of having numeric links
> such as "Go to records: 1-10, 11-20...." I need to have alph links such
> as "Go to records: A-G, H-M, N-T....."
>
> it is difficult to explain but i hope someone can supply me with the
> answer.
>
> thanks
> ryan
Message #4 by "TomMallard" <mallard@s...> on Tue, 30 Oct 2001 07:28:41 -0800
|
|
...
select fieldNames from tableName group by fieldName having
mid(ucase(fieldName), 1, 1) in ['A','B','C'...'G'] order by fieldName
There's one of these for each group, with a button for each on the client to
select the query they want.
tom mallard
seattle
----- Original Message -----
From: "Sam Clohesy" <sam@e...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Tuesday, October 30, 2001 3:07 AM
Subject: [asp_web_howto] RE: paging through a recordset
> Like this?
>
> Page called contact.asp
> <%
>
> DIM conn,rs,strSQL
>
> If Request.Querystring("letter") = "" Then
> sLetter = ""
> else
> sLetter=Request.QueryString("letter")
> end if
> strSQL = "SELECT * FROM contacts ORDER BY ContactLastName ASC "
>
>
> Set rsDisplayName = Server.CreateObject("ADODB.Recordset")
> rsDisplayName.Open strSQL, conn,2
>
> sAlphabet="abcdefghijklmnopqrstuvwxyz"
> DIM sLetters(26)
> For i=1 to 26
> sLetters(i)= MID(sAlphabet,i,1)
> Next
> %>
>
> <b><A class = 'link' HREF="contact.asp?view=1">All</a>|</b><%
> For i=1 to 26
> Set rsDisplayName = Server.CreateObject("ADODB.Recordset")
> rsDisplayName.Open strSQL, conn,2
> isLink = false
> Do While Not rsDisplayName.Eof
>
>
> if UCASE(Left(rsDisplayName("ContactLastName"),1))
UCASE(sLetters(i))
> then
> isLink = true
> Exit Do
> end if
>
>
>
> rsDisplayName.MoveNext
> Loop
>
> rsDisplayName.Close
> Set rsDisplayName=Nothing
>
> if isLink = true then %>
> <b><A class = 'link'
>
HREF="contact.asp?view=1&letter=<%=UCASE(sLetters(i))%>"><%=UCASE(sLetters(i
> ))%></A></b><span class = 'text'>|</span>
> <% else %>
> <span CLASS="deadlinkdarkfaint"><% response.write UCASE(sLetters(i))
> %>
> <% if i < 26 then %><span class = 'text'>|</span><% end if %>
> </span>
> <% end if
> next
>
> %>
>
> -----Original Message-----
> From: Ryan vd Merwe [mailto:ryan@w...]
> Sent: 30 October 2001 09:58
> To: ASP Web HowTo
> Subject: [asp_web_howto] paging through a recordset
>
>
> Hi
>
> how do i page through a recordset, but instead of having numeric links
> such as "Go to records: 1-10, 11-20...." I need to have alph links such
> as "Go to records: A-G, H-M, N-T....."
>
> it is difficult to explain but i hope someone can supply me with the
> answer.
>
> thanks
> ryan
Message #5 by "jonas jerndin" <jonas.jerndin@o...> on Wed, 31 Oct 2001 08:05:40
|
|
I think it would be easier to do it like this:
sqlExp = "select * from links WHERE ID <> 0"
if(Request.QueryString("singeletter")<>"")then
sqlExp = sqlExp & " AND Left(ContactLastName,1)
= '"&Request.QueryString("singeletter")&"'"
end if
sqlExp = sqlExp & " ORDER BY ContactLastName"
|
|
 |