Thursday, March 29, 2012

set date on calendar in a FormView template

Hi,

My calendar is inside a FormView template as users are entering new dates.

I want the month shown to be the same as the last one they entered, but after an Insert, the control revert back to the current month.

I can fetch the moth via SQL or stoer in a cookie, but I don't know how to access the control, as it's embedded in the FormVIew.

Thanks if you can help.

NEIL

1protected void myFormView_DataBound(object sender, EventArgs e)2 {3 Calendar myCal = (Calendar)myFormView.FindControl("myCalendar");4// set the Visible Date in the calendar to the Current Month5 myCal.VisibleDate = DateTime.Now();6 }

Line 3 finds the Calendar Control within the FormView.

Line 5 sets the VisibleDate property of the calendar to the Current Month, or whatever date you want to place on the right side of the =.


Hi,

I'm writing in VB, can you translate?

Cheers,

NEIL


1Protected Sub FormView1_DataBound(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles FormView1.DataBound2Dim myCalAs Calendar =CType(FormView1.FindControl("myCalendar"), Calendar)3 myCal.VisibleDate = DateTime.Now4End Sub
 
If this is what you needed, please mark it as your answer...Thanks!!
 

0 comments:

Post a Comment