ASP.Net GridView/Repeater Date Format

To Format Date in GridView or Repeater ItemTemplate in dd-MM-yyyy or any other preferred format use below code

	<asp:Repeater runat="server" ID="rptContractType" OnItemCommand="rptContractType_ItemCommand">
                                    <ItemTemplate>
                                        <tr>
                                            <td style="text-align: center">                                           
                                                <asp:Label ID="lblNewsDate" runat="server"  Text='<%# Convert.ToDateTime(Eval("NewsDate")).ToString("dd-MM-yyyy") %>'></asp:Label>												
											</td>
										 </tr>
                                   </ItemTemplate>
                             </asp:Repeater>
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s