分页和保存复选框的值

时间:2011-07-04 06:54:04

标签: html sql vbscript asp-classic

我正在使用分页,它使用存储过程按字母过滤。当我按字母过滤提交表单时,我需要保存复选框的值。我有一个previous question类似于这个很好但我希望能够保存我的存储过程。

存储过程:

ALTER PROCEDURE [dbo].[A_Page_Paging]
@selected_Char char(1) = null,
@permissionID int = null
as
if @permissionID = ''
    if @selected_Char = '#'
            select * from A_Page where P_Description like '[^a-z]%'
    else if @selected_Char = '!'
            select * from A_Page
            order by P_Description
    else
            select * from A_Page where P_Description like @selected_Char + '%'
else
    select P_PageID, P_Name, P_Description from A_Permission
    inner join L_PagePermission
    on P_PermissionID = PP_PermissionID
    inner join A_Page
    on P_PageID = PP_PageID
    where P_PermissionID = @permissionID
    order by P_Name

分页按钮:

<input id="buttonStyle" type="submit" name="Paging_Button" value="#">
<% for i = 97 to 122 %>
    <input id="buttonStyle" type="submit" name="Paging_Button" value="<%=CHR(i) %>">&nbsp;
<% next %>
<input id="buttonStyle" type="submit" name="Paging_Button" value="All">

保存复选框和复选框的功能(该功能仅适用于例如如果我选中一个复选框,其值以A开头,然后过滤A,复选框将显示,如果我按B过滤它不会):

   'Checkbox check
        Function CheckedByUser(id)
            Dim x
            CheckedByUser = "checked=""checked"""
            For x=1 To Request.Form("selectedRecord").Count
                If Trim(Request.Form("selectedRecord").Item(x)) = Trim(id) Then
                    Exit Function
                End If
            Next
            CheckedByUser = ""
        End Function

<input type="checkbox" name="selectedRecord" value="<%=objRS("P_PageID")%>" <%=CheckedByUser(objRS("P_PageID")) %>>

修复分页问题的上一个答案,但要求我更改我不想做的存储过程:

<%
Do Until objRS.EOF
    Response.Write("<input type=""checkbox"" name=""selectedRecord"" value=""" & objRS("Id") & """ " & WasCheckedByUser(objRS("Id")))
    If Len(Request.Form("Page"))=1 And Trim(Left(objRS("Id"), 1))<>Trim(Request.Form("Page")) Then
        Response.Write(" style=""display: none;""")
    End If
    Response.Write(" />")
    objRS.MoveNext
Loop
%>

执行存储过程

connectionstring = obj_ADO.getconnectionstring
Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
set objComm = CreateObject("ADODB.Command")
objCon.Open connectionstring

objComm.ActiveConnection = objCon.ConnectionString
objComm.CommandText = "A_Page_Paging"
objComm.CommandType = 4


Set objParameter = objComm.CreateParameter
objParameter.Name = "selected_Char"
objParameter.Type = 129
objParameter.Direction = 1
objParameter.Size = 3
objParameter.Value = Selected_Button
objComm.Parameters.Append objParameter

Set objParameter2 = objComm.CreateParameter
objParameter2.Name = "PermissionID"
objParameter2.Type = 129
objParameter2.Direction = 1
objParameter2 .Size = 3
objParameter2 .Value = P_ID
objComm.Parameters.Append objParameter2

set objRS = objComm.Execute

1 个答案:

答案 0 :(得分:1)

在代码中更改此行:

objParameter.Value = Selected_Button

改为:

objParameter.Value = "!"

循环中已有的代码应该隐藏不属于当前“页面”的复选框。