I have a gridview with 3 columns, in database the date field of the origin table isn’t stored as a date format (the table is in oracle), is stored in string format, so I have my datasource in asp like this
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:OracleXexdb %>"
ProviderName="<%$ ConnectionStrings:OracleXexdb.ProviderName %>"
SelectCommand="select to_date(date, 'mm/dd/yyyy') as date, user, description from mytable where user is not null"
filterexpression = "user LIKE '%{0}%'"
>
</asp:SqlDataSource>
As you can see in the SelectCommand, I convert the date field with the format dd/mm/yyyy (in the database the date format is mm/dd/yyyy); when I run my webpage in the asp.net development server everything is fine, I mean I see the date field with the format dd/mm/yyyy but when I put the webpage on the server I see the mm/dd/yyyy format.
Is there anything I can do? thanks in advance
The most likely reason for the difference when deploying the application is that the culture that will be picked up will be different.
Setting the culture explicitly to the needed one in the Web.config file system.web globalization configuration or on the current thread should resolve the problem.
For example: See Example in Comment Below
The date format can also be specified explicitly on the DatePicker by using the Format method.