Skip to main content
Known Participant
September 25, 2009
Question

Repeat region from 2 different queries (ASP)

  • September 25, 2009
  • 2 replies
  • 1058 views

I have a web site that displays information from 2 different queries. I setup a repeat region to display all the info from one query. I then wrote and If-Then statement to draw the results of the 2nd query based on the Record ID of the 1st query. How do I get the second query results to "loop" or display more than one result. I tried using the repeat region but Dreamweaver gave me an error that nested repeat regions are not allowed.

Any help or direction would be a blessing.

Thank you

This topic has been closed for replies.

2 replies

Participating Frequently
September 25, 2009

I've never tried, but it sounds like DW does not allow nested repeating regions. This isn't surprising. This means that you would need to code the inner repeating region by hand. However, be careful about this. If you are running the inner query once for every outer row, you could swamp the server, especially if you are not reusing connections.

Lon_Winters
Inspiring
September 26, 2009

Here's a free extension that may be just what you need -

http://www.tom-muck.com/extensions/help/simulatednestedregion/

DwFAQ
Participating Frequently
September 25, 2009

As the error message suggested: don't nest the second loop in the first loop and you won't have a problem.

sham_Author
Known Participant
September 25, 2009

Then how does the second query continue to show all records. Right now it stops after finding the first variable.

Here is the code:

<%
While ((Repeat1__numRows <> 0) AND (NOT BLog.EOF))
%>
                                <table width="100%" border="0">
                                  <tr>
                                        <td width="2%" height="62" class="body_text style25"><div align="left"></div>
                                          <div align="right"></div></td>
                                    <td colspan="2" class="body_text style25"><div align="left" class="style25"><img src="../../images/left_quotes.gif" width="21" height="17" align="absbottom" /> <%=(Story.Fields.Item("Story").Value)%> <img src="../../images/right_quotes.gif" width="21" height="17" align="absbottom" />
                                      <input name="fld_StoryD" type="hidden" id="fld_BlogID" value="<%=(Story.Fields.Item("Entry_ID").Value)%>" />
                                    </div></td>
                                  </tr>
                                  <tr>
                                    <td colspan="3" class="style34"><div align="left">
        
         </div>                                        <div align="left" class="style1"> <span class="style44"><%=(Story.Fields.Item("sDate").Value)%> -   <span class="style59"><%=(Story.Fields.Item("FName").Value)%></span> <span class="style45"><span class="style66"><%=(Story.Fields.Item("LName").Value)%></span> - <span class="style44"><%=(Story.Fields.Item("Region_name").Value)%> - <%=(Story.Fields.Item("SC_name").Value)%>/<%=(Story.Fields.Item("Cluster_name").Value)%></span></div></td>
                                  </tr>
                                                                        <% If Not Comments.EOF Or Not Comments.BOF Then %>
                                              </MM:DECORATION> </MM_HIDDENREGION>
                                              <MM_HIDDENREGION><MM:DECORATION OUTLINE="Show%20If..." OUTLINEID=2><img src="../../images/comment.png" width="15" height="15" border="0" /> <a href="Blog_comments.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & "Entry_ID=" & Story.Fields.Item("Entry_ID").Value %>" target="_new" style="color:#811518"><img src="../../images/comments.gif" width="78" height="12" border="0" /></a></MM:DECORATION></MM_HIDDENREGION>
                                              <MM_HIDDENREGION> <MM:DECORATION OUTLINE="Show%20If..." OUTLINEID=2>
                                                <% End If ' end Not Comments.EOF Or NOT Comments.BOF %>
                                    </div></td>
                                    <td width="84%" height="10" valign="top" class="style40"><div align="right"><span class="style1 style42"><a href="Story_comment.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & "Entry_ID=" & Story.Fields.Item("Entry_ID").Value %>" style="color:#811518"><img src="../../images/Leave_comment_button.gif" width="83" height="21" border="0" /></a></span></div></td>
                                  </tr>
                                  <tr>
                                    <td height="10" class="body_text style25"></td>
                                    <td height="10" valign="top" class="body_text style25"> </td>
                                    <td height="10" valign="top" class="style40"><table width="100%" border="0" cellspacing="2" cellpadding="2">
                                      <tr>
                                        <th scope="col"><div align="left">
          <% If (Comments.Fields.Item("Entry_ID").Value) = (story.Fields.Item("Entry_ID").Value) then%>
          <%=(Comments.Fields.Item("Comments").Value)%>
          <% Elseif  Comments.EOF Or Comments.BOF then %>
          <% Response.write("No Comments") %>
          <%End if%>
          </div></th>
                                      </tr>
                                    </table></td>
                                  </tr>
                                  <tr>
                                    <th class="body_text style25" scope="row"></th>
                                      <th height="6" colspan="2" class="body_text style25" scope="row"><div style="font-size:1px; background:#ddd; overflow:hidden; line-height:1px; height:1px"></div></th>
                                  </tr>
                                  <tr>
                                    <th height="2" colspan="3" class="body_text style25" scope="row"></th>
                                  </tr>
                                  </table>
                                <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Story.MoveNext()
Wend
%>