.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Formatting the date with the CalendarExtender

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
I must be missing something here.  I use the code below to display a DateTime value, and the time is always displaying, i.e. 7/11/2010 08:10:10. I just want the date.  The Format value doesn't seem to have any effect.    <asp:TemplateField HeaderText="Exp Date" HeaderStyle-Width="100px">   <ItemTemplate>   <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("expirationDate") %>'></asp:TextBox>   <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1" Format="MM/dd/yy" />   </ItemTemplate>   </asp:TemplateField>

View Complete Post

More Related Resource Links

date formatting


I have a 3 field table in sql server express and one of the columns is a date.

I'm trying to pull that in and publish to a gridview, but when I do it comes in with the date and minutes and seconds, etc.

How can I format that so that I only publish MM/DD/YYYY?

thanks in advance 

CalendarExtender wrong date from database



I'm about to go NUTS :)

I have 2 CalendarExtenders on page. And I want to show the date that I get from SQL SEVER:

select -> SELECT convert(datetime,  begin) as Begin, convert(datetime, end) as End FROM Table

The date field, on base,  is a char(8)  and the record is like YYYYMMDD. That's why I convert it to datetime.

But, on code behind when I do this :

CalendarExtender1.SelectedDate = DateTime.Parse(objDataEvento.Rows(0)(2))
CalendarExtender2.SelectedDate = DateTime.Parse(objDataEvento.Rows(0)(3)) 

Depend of the date, It's showing minus 1 day on page.

Like: If, on base, the date is 08/12/2010, on page it's showing 07/12/2010.

WHYYYYYYYYYYYY ??????????????? Cry Smile




AjaxControlToolkit.CalendarExtender - highlight current date

I have used AjaxControlToolkit.CalendarExtender for calendar in my project.but anyhow I am unable to highlight current date  in calendar control.(Note: Current date I mean is today's date and not the selected date.)e.g.( If today is 15th August 2010, and I have selected 24 August 2010. then when I press calendar icon, I should see 15 august highlighted with different look or same as selected date 24 highlighted in August month of 2010 page in calendar popup.)Please guide me to accomplish the taskThanks in advance for support.

Date Validation and Date Formatting

 Hi,   I am new to ASP.NET 4.0 and the whole Object Oriented Programming.  I added a Calendar Extender on a text box.  Now I would like it to be formatted to MM/DD/YY, PLUS, I also want to validate if the date entered is more than let's say 90 days from today.  If it is more than 90 days, I would like to show something like an error message and set the focus on the date field.  I am writting my code in C#.  Can any body help on this?  Thank you. esant    

Date Time Formatting to a specific dateformat

Hello All,I have been struggling with this for a long time. I have a form in which there is a textbox using an ajax calender extender. Now, the problem is that, I want to take the Date value which is string format and format it to a specific date format before inserting it into the database. The following is the core problem:Dim MDate as string=txtMeetingDate.Textdim d as new Datetime' I want to convert the d to a datetime using the Mdate/// The problem is that I don't know what's the date format in the TextBox because users can use any time format they want, it is based on their windows settings!!!So, I am struggling to change my String (MDate) into a DateTime in the same format the user have and then convert it into my format:"dd/MM/yyyy" and after I have the date in the correct format, I want to change it back to string and save it in the database.I am doing this so that I have the same dateformat saved in my database.Any Ideas? ThanksAMB

Formatting Date consisting of several Fields but no value for the day



     I´m working on some reports with SSRS 2008 and I need to display a date in the format dd.mm.yyyy. Normally that would be easy but the Problem is, that the Date I need to display doesn´t exist as a Field. I have a Field containing the month and another Field containing the year but no field containing the day. Furthermore the day should be always the last day of the month. Does anybody know how to solve this date-puzzle?


Your help would be much appreciated.


XPath Date Formatting Problem


Hey all, just plain and simple I think....lol

Why will this not work?

<asp:Label ID='playDate' runat='server' Text='<%# XPath("LastPlayed", "{0:MMM d yyyy}") %>'></asp:Label>

It completely ignors my date formating and returns this result.


Oh yea, this is in a datalist using an XML datasource.

Date formatting problem with BIDS


I've just moved to a new PC, and had BIDS installed on it.  All machine dates are set to the international standard (dd/MM/yyyy).

I just opened an existing report to modify it that includes a date range in the parameters.  When I tried to do a test preview of the report in BIDS, I got an invalid data error on the first date parameter.  After a bit of fiddling around, I worked out that it would only let me input the dates in US format, yet after input the dates are converted to international format.  When deployed to the report server, the report requires the dates to be input in international format.

I've spent half an hour checking my machine and BIDS to try and find the cause of this problem, and I'm stumped.

Any suggestions?

Date formatting in SPGridview


How can I format the date from 9/23/2010 12:00:00 AM to 9/23/2010 in an SPGridview?

Thanks, Ninel

ajaxtoolkit:CalendarExtender disable the dates which are lessthan current date


 hi frds

i'm using ajaxtoolkit:calenderextender

in this i should not be able to select dates which are lessthan currentdate

is this possible?

how to solve this ?

thank u in advance



CalendarExtender date checker


I have read many forums to see if I could find a solution and there hasn't been anything that is what I need.  I have an asp:calendar that you select a date on there and a panel pops up.  On the panel, the start date and end date are filled with the selected date from the asp:calendar.  The end date field has the CalendarExtender.  When you open it, the selected date on there is the same as from the asp:calendar which is good.  What I need is to tweak my javascript to check to make sure that the user picks a date after the selected date from the asp:calendar.  so if they pick 11/4/2010 as a start date, the end date cannot be fore 11/4/2010.  Only anything after that.  Not todays date(ex. 10/22/2010).

codebehind for my asp:calendar sending the dates

        'post date in panel
        If e.Day.IsSelected Then
            txtSDate.Text = e.Day.Date
            txtEndDate.Text = e.Day.Date
        End If
JavaScript and asp code
        <script type="text/javascript">
            function checkDate(sender, args) {
                if (sender._selectedDate < new Date()) {
                    alert("You cannot select a day earlier than today!&q

SPGridView date formatting



I am using SPGridView in SP2010. I am attaching a datatable to this SPGridView which has a date column in it. But, I dont want to show the timestamp which is comming alongwith the date.

There is no dataFormatString property supported for the SPGridView. How do I achieve the same..?

Thanks in advance..


listview date formatting


i have a listview thats tied to an access database. and at the moment it displays the date like this:

27/10/2010 12:00AM

but i want it to display in long date format like this:

wednesday, 27, october, 2010

how would i achieve this?

thanks for your help in advance!! :)

simple answers with code sample would be appreciated...im only new at this


Date and Time String Formatting With C#.NET

System.DateTime newDate = System.DateTime.Now;
Console.WriteLine("date: {0}", newDate);// Current Date Time will be display

Dates and Times in C# .NET

SSRS 2008 - Passing parameter into textbox - can't seem to apply formatting to it (date/currency)


I have a report that is displaying a parameter in a textbox inside the report.

Now I right clicked on the textbox, went to properties, and set number formatting to: Date - 01/31/2000

However, when I render the report it does not display the date in that format. It displays it in the way the sproc returns it which is: 5/13/2011 3:08:30 PM

I tried changing the parameter type to TEXT instead of datetime, made no difference.

I am having the same problem with currency. I will return 12345 and it will just display that way in the textbox instead of $12,345.00.

Any suggestions?

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

How To Set a Date Format In GridView Using ASP.NET 2.0

A very common desire is to set a column of a gridview to display just the month, day and year of a DateTime type. The problem is the by default, the HtmlEncode property of the boundfield attribute (
The problem is that if this field is enabled, you can not pass format information to the boundfield control. That is, if you try the following code, you will not get the desired result.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend