I'm learning Web Forms, and I'm trying to convert an order form I had been building. I learned about XmlDataSource to source my XML file and Repeater to build a template to present the data, and all is mostly well.
First a sample of how my XML works, and then the problem:
<items>
<item id="sheet-1">
<name>Sheet the First</name>
<price id="single" />
</item>
<item id="sheet-2">
<name>Sheet the Second</name>
<price id="double" />
</item>
</items>
<costs>
<cost id="single">.10</cost>
<cost id="double">.20</cost>
<cost id="triple">.30</cost>
</costs>
With my pre-Web Forms setup, I created a foreach
loop to store all of the cost IDs and values in an array, and then when I looped through each item, I matched the price ID to the cost ID and then output the corresponding value.
I'd like to create the same effect within a Repeater. How I saw it in my head was something like this...
<p class="cost-line">
<%#XPath("../../costs/cost[@id='XPath("price/@id")']") %>
</p>
But I knew that that syntax was highly unlikely to work.
I'm not entirely sure how to word the question. I believe what I'm trying to do is use foreign keys with XPath and Repeaters. Is this possible? If not, what alternatives exist to get where I'm trying to go?