bsp; rs_hasData = rs.next();
}
%>
</tr>
<% } %>
2.将以下代码放在table标签内
<tr>
<% while ((rs_hasData)&&(Repeat1__numRows-- != 0)) { %>
<td>单元格内的动态文本等</td>
<%
Repeat1__index++;
Repeat1__numRows=Repeat1__numRows-1;
rs_hasData = rs.next();
%>
<% if (Repeat1__index%列数==0) { %>
</tr><tr>
<% } %>
<% } %>
十、嵌套显示重复区域:
首先定义“大类记录集rs”,并设整个表格为大类的重复区域。
<% while ((rs_hasData)&&(Repeat1__numRows-- != 0)) { %>
<% int CategoryID=rs.getInt("CategoryID"); %>
<li><a href="category.jsp?CategoryID=<%= CategoryID %>"><%=(((rs_data = rs.getObject("CategoryName"))==null || rs.wasNull())?"":rs_data)%></a>
<ul>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn=DriverManager.getConnection("jdbc:odbc:shop","","");
PreparedStatement pstmt=conn.prepareStatement("select * from SubCategories where CategoryID=?");
pstmt.setInt(1,CategoryID);
ResultSet re=pstmt.executeQuery();
%>
<% while (re.next()) { %>
<li><A HREF="subcategory.jsp?SubCategoryID=<%= re.getInt("SubCategoryID") %>"><%= re.getString("SubCategoryName") %></A></li>
<% } %>
<%
re.close();
pstmt.close();
conn.close();
%>
</ul>
</li>
<%
Repeat1__index++;
rs_hasData = rs.next();
}
%>