私は次のXMLを持っています:
<questions>
<question text="This is a test question?">
<answer value="Yes">
<requirement articleId="2899"/>
</answer>
<answer value="No">
<requirement articleId="2899"/>
</answer>
</question>
</questions>
また、ASPXページに次のマークアップがあります。
<asp:Repeater ID="rptQuestions" runat="server" DataSourceID="xdsQuestions">
<ItemTemplate>
<p>
<asp:Label ID="lblText" runat="server" Text='<%# Eval("text") %>' />
</p>
<div>
<asp:RadioButtonList ID="rblAnswers" runat="server" RepeatDirection="Horizontal"
RepeatLayout="Flow" AutoPostBack="true" OnSelectedIndexChanged="rblAnswers_SelectedIndexChanged"
DataSource='<%# XPathSelect("answer") %>' DataTextField="value" DataValueField="value" />
</div>
</ItemTemplate>
</asp:Repeater>
<asp:XmlDataSource ID="xdsQuestions" runat="server" DataFile="~/App_Data/QA.xml"
XPath="./questions/question" />
これまでのところ、これを機能させる唯一の方法は、「answer」ノードの「value」属性を要素に移動し(次のように<value>Yes</value>
)、「answer」の「InnerText」プロパティにバインドすることです。 XPathSelectがXmlElementのコレクションを返しているため、ノード。'answer'の他の子ノード('requirement'ノードなど)にもInnerTextがある場合、RadioButtonListのListItemsの'value'と連結されるため、これは私がやりたい方法ではありません。 。
XMLを変更せずにRadioButtonListをバインドする方法に関する提案はありますか?