Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sort Repeated Region

    Can any1 tell me how could I sort repeated region??
    I have made repeated region to display records from DB (ID DESC ).

    Now I would like that users can also sort records by name, title, ( ASC or DESC ) in browser!

    Code:
     
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    
    Repeat1__numRows = 15
    Repeat1__index = 0
    loads_numRows = loads_numRows + Repeat1__numRows
    %>
    <% 
    While ((Repeat1__numRows <> 0) AND (NOT loads.EOF)) 
    %>
               <table width="100%" border="0" cellpadding="0" height="20" cellspacing="0" style="border-bottom:1px solid #000000;border-right:1px solid #000000;border-left:1px solid #000000;" bgcolor="">
                   <!--DWLayoutTable-->
                   <tr><%If (Repeat1__numRows Mod 2) Then%>
         <tr style="background-color:#FCEED6">
    <%Else%>
         <tr style="background-color:#ffffff">
    <%End If%>
                      <td width="15%" valign="middle" style="padding-left:5px;"><div align="left"><a href="#" onClick="MyWindow=window.open('http://myserver/myfolder/myfolder1/loads_display.asp?load_id=<%=(loads.Fields.Item("Load_id").Value)%>','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=620'); return false;"><%=(loads.Fields.Item("Load_id").Value)%></a></div></td>
                      <td width="30%" valign="middle" style="padding-left:5px;"><div align="left"><%=(loads.Fields.Item("bullet_weight").Value)%>&nbsp;<%=(loads.Fields.Item("bullet").Value)%></div></td>
                      <td width="30%" valign="middle" style="padding-left:5px;"><div align="left"><%=(loads.Fields.Item("powder").Value)%></div></td>
                      <td width="25%" valign="middle" style="padding-left:5px;"><div align="left"><%=(loads.Fields.Item("unit_mettric_english").Value)%> </div></td>
                   </tr>
               </table>
               <% 
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      loads.MoveNext()
    Wend
    %>
    Thanks,

  • #2
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well what you can do is on your headers for the display table, turn them into links passing in a variable and then use that as the sorting mechanism.
    Code:
    ...
    <tr>
    <th><a href="page.asp?sort=Name">Name</a></th>
    <th><a href="page.asp?sort=Title">Title</a></th>
    </tr>
    ...
    <%
    strSQL = "Select * from table"
    If Request("sort") <> "" Then strSQL = strSQL & " order by " & Request("sort")
    Set rs = Connection.Execute(strSQL)
    %>

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by neocool00
    Well what you can do is on your headers for the display table, turn them into links passing in a variable and then use that as the sorting mechanism.
    Code:
    ...
    <tr>
    <th><a href="page.asp?sort=Name">Name</a></th>
    <th><a href="page.asp?sort=Title">Title</a></th>
    </tr>
    ...
    <%
    strSQL = "Select * from table"
    If Request("sort") <> "" Then strSQL = strSQL & " order by " & Request("sort")
    Set rs = Connection.Execute(strSQL)
    %>
    Not sure if I understand you correctly.
    Also, I get this error al the time:
    Microsoft VBScript runtime (0x800A01A8)
    Object required: ''


    Also here is my rs
    Code:
    <%
    Dim loads__MMColParam
    loads__MMColParam = "1"
    If (Request.QueryString("id") <> "") Then 
      loads__MMColParam = Request.QueryString("id")
    End If
    %>
    <%
    Dim loads
    Dim loads_numRows
    
    Set loads = Server.CreateObject("ADODB.Recordset")
    loads.ActiveConnection = MM_search_STRING
    loads.Source = "SELECT *  FROM [Submit_load Poizvedba]  WHERE id = " + Replace(loads__MMColParam, "'", "''") + "  ORDER BY Load_id DESC" 
    loads.CursorType = 0
    loads.CursorLocation = 2
    loads.LockType = 1
    loads.Open()
    
    loads_numRows = 0
    %>

  • #4
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    See changes in red. Once you make these changes, all you have to do is pass in a request called sort with a value corresponding to one of the columns in your table.
    Code:
    <%
    Dim loads__MMColParam
    loads__MMColParam = "1"
    If (Request.QueryString("id") <> "") Then 
      loads__MMColParam = Request.QueryString("id")
    End If
    %>
    <%
    Dim loads
    Dim loads_numRows
    Dim strSort
    If Request("sort") <> "" Then
    strSort = Request("sort")
    Else
    strSort = "Load_id"
    End If
    
    Set loads = Server.CreateObject("ADODB.Recordset")
    loads.ActiveConnection = MM_search_STRING
    loads.Source = "SELECT *  FROM [Submit_load Poizvedba]  WHERE id = " + Replace(loads__MMColParam, "'", "''") + "  ORDER BY " & strSort & " DESC" 
    loads.CursorType = 0
    loads.CursorLocation = 2
    loads.LockType = 1
    loads.Open()
    
    loads_numRows = 0
    %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •