<%
   ' File:      tablelist.asp
   ' Author:   Marco Tabini
   ' Date:      March 6, 1998
   ' Revision:   2
%>

<%
   ' If no records in table, indicate so

   If rs.RecordCount = 0 Then
%>
      <% if AddEditRecords = True then %>
         <P><A HREF="Record.asp?Operation=NewEdit&Edit=False">Add Record</A>
      <% end if %>
      <P><B>No records in table.</B>
<%
   Else
      ' Browse through the table, one page at a time
      ' The number of records in each page is specified in the 
      ' PageSize variable
%>
      <TABLE>
         <TR>
            <% If Session ("PageNumber") > 0 then %>
            <TD VALIGN=TOP>
               <FORM ACTION="<% = Request.ServerVariables ("SCRIPT_NAME") %>">
                  <INPUT TYPE=HIDDEN NAME="PageNumber" VALUE="<% = Session ("PageNumber") - 1 %>">
                  <INPUT TYPE=HIDDEN NAME="Operation" VALUE="View">
                  <INPUT TYPE=SUBMIT VALUE="<< Previous Page">
               </FORM>
            </TD>
            <% end if %>
            <% if PageSize * (Session ("PageNumber") + 1) - 1 <= Rs.RecordCount then %>
               <TD VALIGN=TOP>
                  <FORM ACTION="<% = Request.ServerVariables ("SCRIPT_NAME") %>">
                     <INPUT TYPE=HIDDEN NAME="PageNumber" VALUE="<% = Session ("PageNumber") + 1 %>">
                     <INPUT TYPE=HIDDEN NAME="Operation" VALUE="View">
                     <INPUT TYPE=SUBMIT VALUE="Next Page >>">
                  </FORM>
               </TD>
            <% end if %>
            <TD VALIGN=TOP>
               Page <% = Session ("PageNumber") + 1 %>
            </TD>
            <% if AddEditRecords = True then %>
               <TD>   
                  <A HREF="Record.asp?Operation=NewEdit&Edit=False">Add Record</A>
               </TD>
            <% end if %>
         </TR>
      </TABLE>

      <TABLE BORDER=0 CELLPADDING=0>
         <TR>
            <TH BGCOLOR="BLACK">
               <FONT COLOR="White">
                  ID #
               </FONT>
            </TH>
      <%
         For Each Field in rs.Fields
      %>
            <TH BGCOLOR="BLACK">
               <FONT COLOR="White">
                  <% = Field.Name %>
               </FONT>
            </TH>
      <%   
         Next
      %>   
         </TR>
      <%
         I = Session ("PageNumber") * PageSize + 1
         SafeMove (I - 1)
         While I mod PageSize <> 0 and not rs.EOF
      %>
         <TR <% If I mod 2 = 0 then %>BGCOLOR=#BFBFFF<% end if %>>
            <TD>
               <A HREF="Record.asp?Operation=View&RowNumber=<% = I - 1 %>"><% = I %></A>&nbsp
            </TD>
      <%
            For Each Field in rs.Fields
      %>   
               <TD>
                  <% = rs (Field.Name) %>&nbsp
               </TD>
      <%
            next
            SafeMovenext
            I = I + 1
         Wend
      %>
         </TR>
      </TABLE>

<% 
   End If 
%>