Populate DropDownList from XmlDataSource

后端 未结 3 638
囚心锁ツ
囚心锁ツ 2021-01-21 20:06

I\'d like to populate my DropDownList using a simple xml file:



  foo         


        
3条回答
  •  野的像风
    2021-01-21 20:30

    I can't recall it from the top of my head but I think there was a bug in XmlDataSource that prevents you to bind to values of xml nodes. It works with attributes only. Please correct me if I am wrong with this. There's a slight modification you need to make to your XML file:

    <%@ Page Language="C#" %>
    
    
    
    
    
        Untitled Page
    
    
        

    Note that I added the name attribute instead of using the value of the node directly.

    If you can't modify the structure of your original XML file you can apply an XSLT transformation on it using the TransformFile property as described in this post.

提交回复
热议问题