Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridview date format 1

Status
Not open for further replies.

NSNewey

Programmer
Joined
Jun 29, 2005
Messages
125
Location
GB
Hi,

I have a gridview with the date columns DataFormatString set to {0:d} and the HtmlEncode set to False.

When I view this in debug mode from Visual Studio, the gridview works properly and formats the dates as required dd/mm/yy

When I upload this to my site, the dates are shown in mm/dd/yyyy format.

Also, when I edit and then update a row, I get an error page. I get no error when running locally.

Any help please?
 
That's great, it works now for the format. Thanks...

The update still doesn't work on the live site though. I thought it may be to do with the dates not displaying correctly then trying to update the wrong format but I still get the error page.

Here is the code from the accessDataSource tag if you have time to look it over.

I am using an access database which is used without error on other pages but these only read not write back.

Here is the code...

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/cs_bookings.mdb"
SelectCommand="SELECT * FROM [tBookedDates] WHERE (Year([StartDate]) = ?) ORDER BY [StartDate]" DeleteCommand="DELETE FROM [tBookedDates] WHERE [BookedDateID] = ?" InsertCommand="INSERT INTO [tBookedDates] ([BookedDateID], [StartDate], [EndDate], [Booked], [PartialBooked], [Price]) VALUES (?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [tBookedDates] SET [StartDate] = ?, [EndDate] = ?, [Booked] = ?, [PartialBooked] = ?, [Price] = ? WHERE [BookedDateID] = ?">
<DeleteParameters>
<asp:Parameter Name="BookedDateID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="StartDate" Type="DateTime" />
<asp:Parameter Name="EndDate" Type="DateTime" />
<asp:Parameter Name="Booked" Type="Boolean" />
<asp:Parameter Name="PartialBooked" Type="Boolean" />
<asp:Parameter Name="Price" Type="Int32" />
<asp:Parameter Name="BookedDateID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="BookedDateID" Type="Int32" />
<asp:Parameter Name="StartDate" Type="DateTime" />
<asp:Parameter Name="EndDate" Type="DateTime" />
<asp:Parameter Name="Booked" Type="Boolean" />
<asp:Parameter Name="PartialBooked" Type="Boolean" />
<asp:Parameter Name="Price" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="comboYear" Name="StartDate" PropertyName="Text"
Type="String" DefaultValue="" />
</SelectParameters>
</asp:AccessDataSource>


 
I believe Access uses # symbols around dates which may cause an issue for you. I would really look at ditching access though if you are going to be using it as a database for a website. SQL Server Express is a much better option if you could use that.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
I could try the # symbols but that wouldn't explain why it works in debug on my local machine.

I'm only using access because I am used to it and this web developement is just a one off. The traffic to this site is very low.

Thanks for your help
 
I could try the # symbols but that wouldn't explain why it works in debug on my local machine.
You obviously have different regional and/or localisation settings to the server so that's one explanation.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Hi,

Just to clarify...

The date format now works OK on the local and internet versions.

Updating data in the gridview works fine on the local version but not the internet version.

I think the gridview's edit/update error may be a different issue to the date problem or do you thing that the localisation settings could cause and update to fail.

Sorry to keep pestering you and thanks for your responses.
 
I would try to set up a testing virutal directory on that same server that has the ability for you to debug so you can upload the code to that new directory and see what formats your dates are in when you try to update. Then fix it from there.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top