title: How to get DataSet.ReadXml to parse a DateTime attribute as a typed DateTime
body: <p>I have an XML string which contains Dates formatted "dd/MM/yyyy hh:mm:ss".</p>
  
  <p>I'm loading this XML into a dataset using <code>DataSet.ReadXml()</code>.</p>
  
  <p>How can I ensure that this Date is stored in the DataSet as a typed DateTime so that I can Sort, Format and RowFilter on it accordingly.</p>
  
  <p>My test harness is as below:</p>
  
  <p>ASPX Page:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XmlDateTypeList.aspx.cs" Inherits="Test.XmlDateTypeList" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server"&gt;
              &lt;Columns&gt;
                  &lt;asp:BoundField DataField="Name" HeaderText="Name" /&gt;
                  &lt;asp:BoundField DataField="Date" HeaderText="Date" DataFormatString="{0:dddd dd MMMM yyyy}" /&gt;
              &lt;/Columns&gt;
          &lt;/asp:GridView&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Code Behind:</p>
  
  <pre><code>using System;
  using System.Data;
  using System.IO;
  using System.Linq;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Xml.Linq;
  
  namespace Test
  {
      public partial class XmlDateTypeList : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              XDocument xDoc = new XDocument(
                  new XElement("List",
                      new XElement("Item",
                          new XAttribute("Name", "A"),
                          new XAttribute("Date", "21/01/2010 00:00:00")
                      ),
                      new XElement("Item",
                          new XAttribute("Name", "B"),
                          new XAttribute("Date", "12/01/2010 00:00:00")
                      ),
                      new XElement("Item",
                          new XAttribute("Name", "C"),
                          new XAttribute("Date", "10/01/2010 00:00:00")
                      ),
                      new XElement("Item",
                          new XAttribute("Name", "D"),
                          new XAttribute("Date", "28/01/2010 00:00:00")
                      )
                  )
              );
  
              DataSet dataSet = new DataSet();
              dataSet.ReadXml(new StringReader(xDoc.ToString()));
  
              GridView1.DataSource = dataSet.Tables[0];
              GridView1.DataBind();
          }
      }
  }
  </code></pre>