asp的offset的一个go to page第12页

2018-09-06 10:34

阅读:758

  
<%@LANGUAGE=VBSCRIPTCODEPAGE=65001%>
<!--#includefile=Connections/conn.asp-->
<%
DimRecordset1
DimRecordset1_cmd
DimRecordset1_numRows

Recordset1_cmd.ActiveConnection=MM_conn_STRING
Recordset1_cmd.Prepared=true

SetRecordset1=Recordset1_cmd.Execute
Recordset1_numRows=0
%>
<%
DimRepeat1__numRows
DimRepeat1__index

Repeat1__numRows=2
Repeat1__index=0
Recordset1_numRows=Recordset1_numRows+Repeat1__numRows
%>

<%
***RecordsetStats,MoveToRecord,andGoToRecord:declarestatsvariables

DimRecordset1_total
DimRecordset1_first
DimRecordset1_last

settherecordcount
Recordset1_total=Recordset1.RecordCount

setthenumberofrowsdisplayedonthispage
If(Recordset1_numRows<0)Then
Recordset1_numRows=Recordset1_total
Elseif(Recordset1_numRows=0)Then
Recordset1_numRows=1
EndIf

setthefirstandlastdisplayedrecord
Recordset1_first=1
Recordset1_last=Recordset1_first+Recordset1_numRows-1

ifwehavethecorrectrecordcount,checktheotherstats
If(Recordset1_total<>-1)Then
If(Recordset1_first>Recordset1_total)Then
Recordset1_first=Recordset1_total
EndIf
If(Recordset1_last>Recordset1_total)Then
Recordset1_last=Recordset1_total
EndIf
If(Recordset1_numRows>Recordset1_total)Then
Recordset1_numRows=Recordset1_total
EndIf
EndIf
%>

<%
***RecordsetStats:ifwedontknowtherecordcount,manuallycountthem

If(Recordset1_total=-1)Then

countthetotalrecordsbyiteratingthroughtherecordset
Recordset1_total=0
While(NotRecordset1.EOF)
Recordset1_total=Recordset1_total+1
Recordset1.MoveNext
Wend

resetthecursortothebeginning
If(Recordset1.CursorType>0)Then
Recordset1.MoveFirst
Else
Recordset1.Requery
EndIf

setthenumberofrowsdisplayedonthispage
If(Recordset1_numRows<0OrRecordset1_numRows>Recordset1_total)Then
Recordset1_numRows=Recordset1_total
EndIf

setthefirstandlastdisplayedrecord
Recordset1_first=1
Recordset1_last=Recordset1_first+Recordset1_numRows-1

If(Recordset1_first>Recordset1_total)Then
Recordset1_first=Recordset1_total
EndIf
If(Recordset1_last>Recordset1_total)Then
Recordset1_last=Recordset1_total
EndIf

EndIf
%>
<%
DimMM_paramName
%>
<%
***MoveToRecordandGoToRecord:declarevariables

DimMM_rs
DimMM_rsCount
DimMM_size
DimMM_uniqueCol
DimMM_offset
DimMM_atTotal
DimMM_paramIsDefined

DimMM_param
DimMM_index

SetMM_rs=Recordset1
MM_rsCount=Recordset1_total
MM_size=Recordset1_numRows
MM_uniqueCol=id
MM_paramName=page
MM_offset=0
MM_atTotal=false
MM_paramIsDefined=false
If(MM_paramName<>)Then
MM_paramIsDefined=(Request.QueryString(MM_paramName)<>)
EndIf
%>
<%
***MoveToRecord:handleindexoroffsetparameter

if(NotMM_paramIsDefinedAndMM_rsCount<>0)then

useindexparameterifdefined,otherwiseuseoffsetparameter
MM_param=Request.QueryString(index)
If(MM_param=)Then
MM_param=Request.QueryString(offset)
EndIf
If(MM_param<>)Then
MM_offset=Int(MM_param)
EndIf

ifwehavearecordcount,checkifwearepasttheendoftherecordset
If(MM_rsCount<>-1)Then
If(MM_offset>=MM_rsCountOrMM_offset=-1)Thenpastendormovelast
If((MM_rsCountModMM_size)>0)Thenlastpagenotafullrepeatregion
MM_offset=MM_rsCount-(MM_rsCountModMM_size)
Else
MM_offset=MM_rsCount-MM_size
EndIf
EndIf
EndIf

movethecursortotheselectedrecord
MM_index=0
While((NotMM_rs.EOF)And(MM_index<MM_offsetOrMM_offset=-1))
MM_rs.MoveNext
MM_index=MM_index+1
Wend
If(MM_rs.EOF)Then
MM_offset=MM_indexsetMM_offsettothelastpossiblerecord
EndIf

EndIf
%>
<%
***MoveToSpecificRecord:handledetailparameter

If(MM_paramIsDefinedAndMM_rsCount<>0)Then

getthevalueoftheparameter
MM_param=Request.QueryString(MM_paramName)

findtherecordwiththeuniquecolumnvalueequaltotheparametervalue
MM_offset=0
DoWhile(NotMM_rs.EOF)
If(CStr(MM_rs.Fields.Item(MM_uniqueCol).Value)=MM_param)Then
ExitDo
EndIf
MM_offset=MM_offset+1
MM_rs.MoveNext
Loop

ifnotfound,setthenumberofrecordsandresetthecursor
If(MM_rs.EOF)Then
If(MM_rsCount<0)Then
MM_rsCount=MM_offset
EndIf
If(MM_size<0OrMM_size>MM_offset)Then
MM_size=MM_offset
EndIf
MM_offset=0

resetthecursortothebeginning
If(MM_rs.CursorType>0)Then
MM_rs.MoveFirst
Else
MM_rs.Close
MM_rs.Open
EndIf
EndIf

EndIf
%>
<%
***MoveToRecord:ifwedontknowtherecordcount,checkthedisplayrange

If(MM_rsCount=-1)Then

walktotheendofthedisplayrangeforthispage
MM_index=MM_offset
While(NotMM_rs.EOFAnd(MM_size<0OrMM_index<MM_offset+MM_size))
MM_rs.MoveNext
MM_index=MM_index+1
Wend

ifwewalkedofftheendoftherecordset,setMM_rsCountandMM_size
If(MM_rs.EOF)Then
MM_rsCount=MM_index
If(MM_size<0OrMM_size>MM_rsCount)Then
MM_size=MM_rsCount
EndIf
EndIf

ifwewalkedofftheend,settheoffsetbasedonpagesize
If(MM_rs.EOFAndNotMM_paramIsDefined)Then
If(MM_offset>MM_rsCount-MM_sizeOrMM_offset=-1)Then
If((MM_rsCountModMM_size)>0)Then
MM_offset=MM_rsCount-(MM_rsCountModMM_size)
Else
MM_offset=MM_rsCount-MM_size
EndIf
EndIf
EndIf

resetthecursortothebeginning
If(MM_rs.CursorType>0)Then
MM_rs.MoveFirst
Else
MM_rs.Requery
EndIf

movethecursortotheselectedrecord
MM_index=0
While(NotMM_rs.EOFAndMM_index<MM_offset)
MM_rs.MoveNext
MM_index=MM_index+1
Wend
EndIf
%>
<%
***MoveToRecord:updaterecordsetstats

setthefirstandlastdisplayedrecord
Recordset1_first=MM_offset+1
Recordset1_last=MM_offset+MM_size

If(MM_rsCount<>-1)Then
If(Recordset1_first>MM_rsCount)Then
Recordset1_first=MM_rsCount
EndIf
If(Recordset1_last>MM_rsCount)Then
Recordset1_last=MM_rsCount
EndIf
EndIf

setthebooleanusedbyhideregiontocheckifweareonthelastrecord
MM_atTotal=(MM_rsCount<>-1AndMM_offset+MM_size>=MM_rsCount)
%>
12下一页阅读全文


评论


亲,登录后才可以留言!