Solved

Sorting A Gridview With An XML File As Its Datasource

Posted on 2008-10-22
4
295 Views
Last Modified: 2012-05-05
I want to programatically sort my Gridview upon page load. The datasource is an XML file with the 50 US States, but they are not in alphabetical order in the XML file. I want my Gridview to sort alphabetically by statename upon page load (I don't need the user to be able to sort manually), but I am getting the following error:

"Cannot find column name."

I checked this article http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22892423.html but they never actually explain how to do this without having to write an XSL file.

Here is my VB:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack = False Then
            BindGrid()
        End If
    End Sub

    Sub BindGrid()
        Dim ds As New DataSet
        ds.ReadXml(Request.PhysicalApplicationPath + "usa_locator.xml")
        Dim dv As DataView = ds.Tables(0).DefaultView
        dv.Sort = "name"
        GridView1.DataSource = dv
        GridView1.DataMember = "state"
        GridView1.DataBind()
    End Sub

And here is the XML:
<?xml version="1.0" standalone="yes"?>

<usa_fix>

  <config>

    <color_map>0x7798BA</color_map>

    <color_map_over>0x366CA3</color_map_over>

    <quantity>51</quantity>

    <background_color>0xE5EBF4</background_color>

    <show_links>0</show_links>

  </config>

  <map_data>

    <state>

      <id>1</id>

      <name>Washington</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>2</id>

      <name>Idaho</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>3</id>

      <name>Montana</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>4</id>

      <name>North Dakota</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>5</id>

      <name>Minnesota</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>6</id>

      <name>Wisconsin</name>

      <link>javascript:set_text('&lt;P&gt;Total Equity Placed - $4,665,667&lt;/P&gt;

&lt;P&gt;Total Units Completed - 95&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Blue Ribbon Lofts.JPG" src="/MapEditor/images/Blue%20Ribbon%20Lofts.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>7</id>

      <name>Michigan</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $70,458,641&lt;/p&gt;

&lt;p&gt;Total Units Completed - 1,885&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>8</id>

      <name>Oregon</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>9</id>

      <name>Wyoming</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>10</id>

      <name>South Dakota</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>11</id>

      <name>Iowa</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>12</id>

      <name>Illinois</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $46,047,570&lt;/p&gt;

&lt;p&gt;Total Units Completed - 1,710&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>13</id>

      <name>Indiana</name>

      <link>javascript:set_text('&lt;P&gt;Total Equity Placed - $128,936,936&lt;/P&gt;

&lt;P&gt;Total Units Completed - 3,630&lt;/P&gt;

&lt;P&gt;&lt;IMG style="WIDTH: 100px; HEIGHT: 84px" height=768 alt="Connie Jean Garrett.jpg" src="/MapEditor/images/Connie%20Jean%20Garrett.jpg" width=1024 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Christamore ct Indy.JPG" src="/MapEditor/images/Christamore%20ct%20Indy.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Arbors at princeton park columbus.JPG" src="/MapEditor/images/Arbors%20at%20princeton%20park%20columbus.JPG" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Connie Jean II Garrett IN.jpg" src="/MapEditor/images/Connie%20Jean%20II%20Garrett%20IN.jpg" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Betz sr villas auburn.jpg" src="/MapEditor/images/Betz%20sr%20villas%20auburn.jpg" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Constitution Gardens INdy.JPG" src="/MapEditor/images/Constitution%20Gardens%20INdy.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Brooklyn Manor fort wayne.jpg" src="/MapEditor/images/Brooklyn%20Manor%20fort%20wayne.jpg" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Eastland 112807 014.JPG" src="/MapEditor/images/Eastland%20112807%20014.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="chestnut hills fort wayne.JPG" src="/MapEditor/images/chestnut%20hills%20fort%20wayne.JPG" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Hauenstein Hills II.JPG" src="/MapEditor/images/Hauenstein%20Hills%20II.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Heron Preserve II.JPG" src="/MapEditor/images/Heron%20Preserve%20II.JPG" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Heron Preserve Warsaw.jpg" src="/MapEditor/images/Heron%20Preserve%20Warsaw.jpg" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Jerry Junction Grand Opening 002.jpg" src="/MapEditor/images/Jerry%20Junction%20Grand%20Opening%20002.jpg" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt=Maysville.JPG src="/MapEditor/images/Maysville.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Pine Glen Indy.jpg" src="/MapEditor/images/Pine%20Glen%20Indy.jpg" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Prairie Apt South Bend.JPG" src="/MapEditor/images/Prairie%20Apt%20South%20Bend.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="preserve at fir road mishawaka.JPG" src="/MapEditor/images/preserve%20at%20fir%20road%20mishawaka.JPG" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Sacred Heart.bmp" src="/MapEditor/images/Sacred%20Heart.bmp" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Stellhorn Fort Wayne.jpg" src="/MapEditor/images/Stellhorn%20Fort%20Wayne.jpg" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Stephanie Villas Fort Wayne.JPG" src="/MapEditor/images/Stephanie%20Villas%20Fort%20Wayne.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Tilwater Pt fort wayne.jpg" src="/MapEditor/images/Tilwater%20Pt%20fort%20wayne.jpg" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Trail Ridge Columbia City IN.JPG" src="/MapEditor/images/Trail%20Ridge%20Columbia%20City%20IN.JPG" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="Turtle Creek indy.JPG" src="/MapEditor/images/Turtle%20Creek%20indy.JPG" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="Valley Forge Indy.jpg" src="/MapEditor/images/Valley%20Forge%20Indy.jpg" width=100 border=0&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG height=75 alt="tyler terrace fort wayne.JPG" src="/MapEditor/images/tyler%20terrace%20fort%20wayne.JPG" width=100 border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG height=75 alt="village corydon.JPG" src="/MapEditor/images/village%20corydon.JPG" width=100 border=0&gt;&lt;/P&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>14</id>

      <name>Ohio</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $71,814,273&lt;/p&gt;

&lt;p&gt;Total Units Completed - 2,543&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>15</id>

      <name>California</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $10,263,396&lt;/p&gt;

&lt;p&gt;Total Units Completed - 112&lt;br /&gt;

&amp;nbsp;&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>16</id>

      <name>Nevada</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>17</id>

      <name>Utah</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>18</id>

      <name>Colorado</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>19</id>

      <name>Nebraska</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>20</id>

      <name>Kansas</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>21</id>

      <name>Missouri</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $4,868,373&lt;/p&gt;

&lt;p&gt;Total Units Completed - 162&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>22</id>

      <name>Kentucky</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $9,871,416&lt;/p&gt;

&lt;p&gt;Total Units Completed - 276&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>23</id>

      <name>Arizona</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>24</id>

      <name>New Mexico</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>25</id>

      <name>Texas</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>26</id>

      <name>Oklahoma</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>27</id>

      <name>Arkansas</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>28</id>

      <name>Louisiana</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>29</id>

      <name>Mississippi</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>30</id>

      <name>Tennessee</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $6,971,751&lt;/p&gt;

&lt;p&gt;Total Units Completed&amp;nbsp;- 192&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>31</id>

      <name>Alabama</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>32</id>

      <name>Georgia</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>33</id>

      <name>Florida</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $20,458,271&lt;/p&gt;

&lt;p&gt;Total Units Completed - 203&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>34</id>

      <name>West Virginia</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>35</id>

      <name>Maryland</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>36</id>

      <name>Pennsylvania</name>

      <link>javascript:set_text('&lt;p&gt;Total Equity Placed - $11,757,598&lt;/p&gt;

&lt;p&gt;Total Units Completed - 147&lt;/p&gt;');</link>

      <info />

      <color_map>0x244061</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>37</id>

      <name>New York</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>38</id>

      <name>Vermont</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>39</id>

      <name>New Hampshire</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>40</id>

      <name>Maine</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>41</id>

      <name>Massachusetts</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>42</id>

      <name>Rhode Island</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>43</id>

      <name>Connecticut</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>44</id>

      <name>New Jersey</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>45</id>

      <name>Delaware</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>46</id>

      <name>Virginia</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>47</id>

      <name>North Carolina</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>48</id>

      <name>South Carolina</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>49</id>

      <name>Alaska</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>50</id>

      <name>Hawaii</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>51</id>

      <name>District of Columbia</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

    <state>

      <id>52</id>

      <name>Puerto Rico</name>

      <link>javascript:set_text('');</link>

      <info />

      <color_map>0x366092</color_map>

      <color_map_over>0x95B3D7</color_map_over>

      <color_map_active>0xF26522</color_map_active>

    </state>

  </map_data>

</usa_fix>

Open in new window

0
Comment
Question by:CitySec
  • 2
  • 2
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
Have you examined the structure that is inferred from the DataSet.ReadXml call?  Sometimes it infers a structure that you didn't expect.  You can loop through the DataSet's Tables collection, and print out each table name and each column name for the tables.
0
 
LVL 2

Author Comment

by:CitySec
Comment Utility
For anyone else who comes across this same problem, using the advice of TheLearnedOne, I found out what I was doing wrong.

The structure of my XML document required me to change this line of code:

Dim dv As DataView = ds.Tables(0).DefaultView

To this:

Dim dv As DataView = ds.Tables(2).DefaultView

I had to load the right node of the XML document - I was just loading the whole thing when I really wanted the <state> node.
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
I see where you use the ordinal index for the table, but I feel that you should use the table instead:

Example:
  Dim dv As DataView = ds.Tables("map_data")

That would be more readable.
0
 
LVL 2

Author Comment

by:CitySec
Comment Utility
Had to do it like this:

Dim dv As DataView = ds.Tables("state").DefaultView

But it worked, and I agree it's much more readable that way.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now