title: Display Local Time in GridView
body: <p>I have an asp.net gridview bound to the following sql server 2008r2 data source:</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="dsFault" runat="server" DataSourceMode="DataSet" 
   ConnectionString="&lt;%$ ConnectionStrings:ESBExceptionDb %&gt;"
  SelectCommand="select * from Fault order by datetime desc"&gt;&lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>In my Fault table there is a column called DateTime of type datetime. The values  stored in this column are in UTC format and I need them to be displayed in the local timezone for the browser</p>
  
  <p>I have added a template field to the Columns collection of the grid view as follows:</p>
  
  <pre><code>&lt;asp:TemplateField&gt;
    &lt;ItemTemplate&gt;
     &lt;asp:Label ID="lblLocalTime" runat="server" 
      Text='&lt;%# String.Format("{0:f}", Eval("DateTime").ToLocalTime()) %&gt;'&gt;
     &lt;/asp:Label&gt;
    &lt;/ItemTemplate&gt;    
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>When I browse the page I get the following error:</p>
  
  <pre><code>CS1061: 'object' does not contain a definition for 'ToLocalTime' and no
  extension method 'ToLocalTime' accepting a first argument of type 'object' 
  could be found (are you missing a using directive or an assembly reference?)
  </code></pre>
  
  <p>Can anyone please tell me where I've gone wrong?</p>
  
  <p>Thanks, Rob.</p>