Tuesday, March 28, 2017

xmldatasource

For those of us still stuck supporting and enhancing web forms apps, sometimes it is useful to use an xmldatasource to as fake data until the underlying structure can be worked out.  Pasting a sample of an xmldatasource here to remind me of it's format in the future.  This is what you need for combo boxes



<asp:XmlDataSource ID="MyDataSet" runat="server" XPath="/items/item">
      <Data>
       <items>
        <item desc="field_one" val="some value" />
        <item desc="field_two" val="escape invalid chars" />
        <item desc="field_three" val="vals can by any type just put them line like a string" />
        <item desc="field_four" val="And so on, and so on, and so on" />
       </items>
      </Data>
    </asp:XmlDataSource>

To databind xmlsources to grids, you want the data to be laid out more like this

<asp:XmlDataSource ID="MyDataSet" runat="server" XPath="/items/item">
      <Data>
       <items>
        <item field_one="some value" field_two="escape invalid chars" field_three="vals can by any type just put them lin like a string" field_four="And so on, and so on, and so on" />
        <item field_one="some other value" field_two="escape invalid chars" field_three="vals can by any type just put them lin like a string" field_four="And so on, and so on, and so on" />
      </items>
      </Data>
    </asp:XmlDataSource>