Sunday, June 17, 2012

how to remove time from datetime and display in a gridview

When we  load a Gridview from database value. by default it shows time with date in gridview column.
look like

if we want to show only date without the time then we have to add 2 property in column binding. HtmlEncode="False" DataFormatString="{0:d}"

The gridview aspx bind will be

             <asp:BoundField DataField="DistributorId" HeaderText="Distributor Id" />  
             <asp:BoundField DataField="Status" HeaderText="Status" />  
             <asp:BoundField DataField="ProductLine" HeaderText="Product Line" />  
             <asp:BoundField DataField="OrderID" HeaderText="Order Id" />  
             <asp:BoundField DataField="OrderDate" HeaderText="Order Date" HtmlEncode="False"  
               DataFormatString="{0:d}" />  
             <asp:BoundField DataField="EmployeeId" HeaderText="Employee Id" />  
             <asp:BoundField DataField="MessageId" HeaderText="Message Id" />  
             <asp:BoundField DataField="SendDate" HeaderText="Send Date" HtmlEncode="False" DataFormatString="{0:d}" />  

the the gridview will llok like

vfpoledeb.1 provider is not registered on the local machine

Have u Install VFP Ole DB Provider in your System ? If No then Please Install it from following link.