xml ファイル内のデータからドロップダウンをバインドする際に問題が発生しています。xml ファイルは次のようになります。
<agricultural>
<file>
<text>Acreage_Cotton_Planted</text>
<value>ACRECOTP Index</value>
</file>
<file>
<text>Acreage_Corn_Planted</text>
<value>ACRECRNP Index</value>
</file>
<file>
<text>Acreage_Soybean_Planted</text>
<value>ACRESOYP Index</value>
</file>
<file>
<text>Acreage_Wheat_Planted</text>
<value>ACREWHTP Index</value>
</file>
</agricultural>
このコードを使用して、xml からリストを返しています
Public Shared Function GetAgDataList(nodestring As String) As List(Of ListItem)
Dim doc As New XmlDocument()
'Load XML from the file into XmlDocument object
doc.Load("~\DataFiles\dataXML.xml") 'this needs to be changed to the server path
Dim root As XmlNode = doc.DocumentElement
'Select all nodes with the tag paramter indicated by the nodestring variable
Dim nodeList As XmlNodeList = root.SelectNodes(nodestring)
Return (From node As XmlNode In nodeList Let text = node.Attributes.GetNamedItem("text").Value.ToString() Let val = node.Attributes.GetNamedItem("value").Value.ToString() Select New ListItem(text, val)).ToList()
End Function
ドロップダウン リスト コントロールは、テキストを表示するだけではありませんか? 私のドロップダウンには、テキストと値が連結されて表示されているためです。たとえば、Acreage_Corn_PlantedACRECRNP インデックスです。Acreage_Corn_Planted というテキストだけを表示します。