Calendar control - current month only

S

stevebuy

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.
 
C

Chris Fulstow

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
 
G

Guest

Hi Steve,

Set the todaysdate property of the calender control.

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

The calender will start in that month.
 
S

stevebuy

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!!
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top