Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Am I missing something here? </p> <p>Can't you simply comment/remove your doc.Load(Server.MapPath("~/myxml/bookstore.xml")) out within your itemDB Sub? Since you defined doc "globally" and already loaded it on page load? <em>(by doing that you will already avoid reloading the xml)</em></p> <p>That said, I do agree with Caspar that you should rather use the XmlDatasource <em>(especially for its caching abilities)</em>, you don't have to use the XmlDatasource within your markup - you can always define it within your code-behind as well - Since you're concerned about people seeing your <em>(asp.net server-side based)</em> markup for some reason...</p> <p>e.g.</p> <pre><code>Public Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim source As New XmlDataSource() source.DataFile = "~/myxml/bookstore.xml" source.XPath = "Bookings/Booking[@CLIENT_NO='SA33762']" rpMyRepeater.DataSource = source rpMyRepeater.DataBind() End If End Sub </code></pre> <p>Markup: <em>(Nice thing you'll notice here, is that we bind the second repeater using the source from the first repeater)</em> </p> <pre><code>&lt;asp:Repeater ID="rpMyRepeater" runat="server"&gt; &lt;ItemTemplate&gt; &lt;%#XPath("//Booking/NAME/text()")%&gt; &lt;asp:Repeater runat="server" ID='books' DataSource='&lt;%#XPathSelect("//Booking/Products/Book") %&gt;'&gt; &lt;HeaderTemplate&gt; &lt;h2&gt; Books&lt;/h2&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;p&gt; Title: &lt;%#XPath("TITLE/text()")%&gt;&lt;/p&gt; &lt;p&gt; &lt;%#XPath("BOOKCODE/text()")%&gt;&lt;/p&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>XML</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;Bookings&gt; &lt;Booking CLIENT_NO="SA33762"&gt; &lt;NAME&gt;Mr Pf_Test_15033&lt;/NAME&gt; &lt;Products&gt; &lt;Book&gt; &lt;TITLE&gt;My Book&lt;/TITLE&gt; &lt;BOOKCODE&gt;12345&lt;/BOOKCODE&gt; &lt;/Book&gt; &lt;Book&gt; &lt;TITLE&gt;My Book2&lt;/TITLE&gt; &lt;BOOKCODE&gt;123456&lt;/BOOKCODE&gt; &lt;/Book&gt; &lt;/Products&gt; &lt;/Booking&gt; &lt;/Bookings&gt; </code></pre> <p>The implementation using the ListView control <em>(one of my favorite asp.net control)</em> will look something like this: <em>(If there's no books available, it will display the markup within the EmptyDataTemplate)</em></p> <pre><code>&lt;asp:Repeater ID="rpMyRepeater" runat="server"&gt; &lt;ItemTemplate&gt; &lt;%#XPath("//Booking/NAME/text()")%&gt; &lt;asp:ListView runat="server" ID="books" ItemPlaceholderID="phItems" DataSource='&lt;%#XPathSelect("//Booking/Products/Book") %&gt;'&gt; &lt;LayoutTemplate&gt; &lt;h2&gt; Books&lt;/h2&gt; &lt;asp:PlaceHolder runat="server" ID="phItems"&gt;&lt;/asp:PlaceHolder&gt; &lt;/LayoutTemplate&gt; &lt;ItemTemplate&gt; &lt;p&gt; Title: &lt;%#XPath("TITLE/text()")%&gt;&lt;/p&gt; &lt;p&gt; &lt;%#XPath("BOOKCODE/text()")%&gt;&lt;/p&gt; &lt;/ItemTemplate&gt; &lt;EmptyDataTemplate&gt; &lt;p&gt; Sorry no books available&lt;/p&gt; &lt;/EmptyDataTemplate&gt; &lt;/asp:ListView&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload