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

SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...