Home > ASP.Net > Bind date format in BoundField using your web.config settings

Bind date format in BoundField using your web.config settings


Hi

try this example:

First: in your web.config

<configuration>
      <configSections>
            <add key=“GridDateFormat“ value=“{0:dd/MM/yyyy}” />
      </configSections>
</configuration>

Second :You can apply any date format other than “dd/MM/yyyy” as per your need, now how to access this date format in Grid view? is very important, so below is the code, that defines how to access web.config file’s date format in your GridView:

<asp:BoundField HtmlEncode=”False” DataField=”CreatedDate”  SortExpression=”CreatedDate” HeaderText=”Created Date” DataFormatString=”<%$Appsettings:GridDateFormat%>“/>

Good Luck

Advertisements
Categories: ASP.Net
  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: