Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Calendar control - current month only

Reply
Thread Tools

Calendar control - current month only

 
 
stevebuy@eircom.net
Guest
Posts: n/a
 
      04-13-2006
Hi, I hope I'm posting this in the right forum.

I'm using a calendar control in a detailsview template (aspnet 2.0).
Its bound to data but in the edit view it always displays the current
month, not the month containing the date that the control is bound to.
How do I get it to display the month associated with the underlying
data (rather than having to manually move to it).

Many thanks in advance for any help on the matter.

 
Reply With Quote
 
 
 
 
Chris Fulstow
Guest
Posts: n/a
 
      04-13-2006
Hi,

Maybe you can use the DetailsView_ItemUpdating event to set the
Calendar.SelectedDate property? Probably not the manual approach
you're looking for...

HTH,
Chris

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RHVzdGluIHZhbiBkZSBTYW5kZSBbTUNBRF0=?=
Guest
Posts: n/a
 
      04-13-2006
Hi Steve,

Set the todaysdate property of the calender control.

Calendar1.TodaysDate = new DateTime(2005, 12, 01);

The calender will start in that month.

"" wrote:

> Hi, I hope I'm posting this in the right forum.
>
> I'm using a calendar control in a detailsview template (aspnet 2.0).
> Its bound to data but in the edit view it always displays the current
> month, not the month containing the date that the control is bound to.
> How do I get it to display the month associated with the underlying
> data (rather than having to manually move to it).
>
> Many thanks in advance for any help on the matter.
>
>

 
Reply With Quote
 
stevebuy@eircom.net
Guest
Posts: n/a
 
      04-13-2006
Many thanks for the input guys, but I'm still getting the current month
to show up in edit mode rather than the month with the bound date.

It would be great if there was some sort of "DefaultDisplayMonth='<%#
Bind("DueDate") %>" that I could add to the <EditItemTemplate> below.
<EditItemTemplate>
<asp:Calendar ID="Calendar1" runat="server"
SelectedDate='<%# Bind("DueDate") %>'></asp:Calendar>
</EditItemTemplate>


Following the advice above I've also messed around with :-

Protected Sub DetailsView1_ModeChanging(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DetailsViewModeEventArgs ) Handles
DetailsView1.ModeChanging

If e.NewMode = DetailsViewMode.Edit Then
CType(DetailsView1.FindControl("Calendar1"),
Calendar).TodaysDate = "11-11-2005"
End If
End Sub

Anyway I'm using a SQLDataSource so would have to switch it to a
dataset to access the "bound date" here.

I hope I'm making some sense - as ye can see I'm not very good with
this!!

 
Reply With Quote
 
=?Utf-8?B?RHVzdGluIHZhbiBkZSBTYW5kZSBbTUNBRF0=?=
Guest
Posts: n/a
 
      04-13-2006
Steve,

I don't believe ModeChanging is the right event for changing the TodaysDate
property. Try putting it in the Detailsview_prerender and check if the
currentmode is edit mode.

Todaysdate is the property to use. I'm sure.

Good luck.

"" wrote:

> Many thanks for the input guys, but I'm still getting the current month
> to show up in edit mode rather than the month with the bound date.
>
> It would be great if there was some sort of "DefaultDisplayMonth='<%#
> Bind("DueDate") %>" that I could add to the <EditItemTemplate> below.
> <EditItemTemplate>
> <asp:Calendar ID="Calendar1" runat="server"
> SelectedDate='<%# Bind("DueDate") %>'></asp:Calendar>
> </EditItemTemplate>
>
>
> Following the advice above I've also messed around with :-
>
> Protected Sub DetailsView1_ModeChanging(ByVal sender As Object, ByVal e
> As System.Web.UI.WebControls.DetailsViewModeEventArgs ) Handles
> DetailsView1.ModeChanging
>
> If e.NewMode = DetailsViewMode.Edit Then
> CType(DetailsView1.FindControl("Calendar1"),
> Calendar).TodaysDate = "11-11-2005"
> End If
> End Sub
>
> Anyway I'm using a SQLDataSource so would have to switch it to a
> dataset to access the "bound date" here.
>
> I hope I'm making some sense - as ye can see I'm not very good with
> this!!
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cal control - pre selecting a date from last month - and the calendar still shows this month. Mufasa ASP .Net 0 09-05-2008 06:51 PM
displaying only current month dates asp.net calendar control prasanthamohan Software 0 07-18-2006 06:43 AM
Get the month and year of Calendar that current displaying =?Utf-8?B?SmFzb24gQ2hhbg==?= ASP .Net 4 11-23-2005 04:19 PM
Web calendar control to display a single month only M. D'Costa ASP .Net Web Controls 3 09-23-2004 01:45 PM
How to make a week view and day view calendar just like month view calendar in .NET ? Parthiv Joshi ASP .Net Web Controls 1 07-06-2004 03:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57