Imar,
That is odd-I ran your example, and you're right, the correct date was passed through.
(JUST EDITED - Imar - you are on to something as when I comment out the refresh function, it works---so, now need to step back and figure out how to get this to work - as I am using the refresh function to "highlight" or select the dates that have events tied to them so a user can see, at first glance, which dates have events...it must be doing something to "selecteddates"....hmmm)
Here's my page:
Here's the RefreshCalendar Method:
I was finding myself using this quite often in a similar page. I'm trying to pre-populate the Calendar with all of the Events in the database that match the current month's month and year so that a user could see all the dates where events are listed.
Public Sub RefreshCalendar(ByVal myCalendar As Calendar, ByVal myMonth As Integer, ByVal myYear As Integer)
Dim myEventDates As New List(Of Date)
Dim myEvents As New CAGEventList
myEvents = CAGEventDB.GetEventDates(myMonth, myYear)
If Not myEvents Is Nothing Then
For Each myCAGEVent As CAGEvent In myEvents
myEventDates.Add(myCAGEVent.eventDate)
Next
For Each myDate As Date In myEventDates
myCalendar.SelectedDates.Add(myDate)
Next
End If
End Sub
CheckEnrollments.aspx:
<div id='enrollleft'>
<h2>    Check Enrolls</h2>
<asp:Calendar ID="Calendar1" runat="server">
<OtherMonthDayStyle CssClass="calendarotherday" />
</asp:Calendar>
<asp:GridView ID="GridView1" runat="server" GridLines="None" ShowHeader="False"
AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
<Columns>
<asp:BoundField DataField="FName" HeaderText="FName" SortExpression="FName" />
<asp:BoundField DataField="LName" HeaderText="LName" SortExpression="LName" />
<asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
<asp:BoundField DataField="MobPhone" HeaderText="MobPhone"
SortExpression="MobPhone" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetMembersInEventByDate"
TypeName="Searing.Sprint.CustomerAdvocacy.Bll.Memb erManager">
<SelectParameters>
<asp:ControlParameter ControlID="Calendar1" Name="myDate"
PropertyName="SelectedDate" Type="DateTime" />
</SelectParameters>
</asp:ObjectDataSource>
Here's the Select Method in my MemberManager.vb class:
Public Shared Function GetMembersInEventByDate(ByVal myDate As Date) As MemberList
Return MemberDB.GetMembersEnrolledInEventByDate(myDate)
End Function
Here's the method in the MemberDB Class:
Public Shared Function GetMembersEnrolledInEventByDate(ByVal myDate As Date) As MemberList
Dim tempList As MemberList = Nothing
' Using
Dim myConnection As SqlConnection = New SqlConnection(AppConfiguration.ConnectionString)
Try
Dim myCommand As SqlCommand = New SqlCommand("sprocMemberSelectListByEventDate", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.AddWithValue("@myDate", myDate)
myConnection.Open()
' Using
Dim myReader As SqlDataReader = myCommand.ExecuteReader
Try
If myReader.HasRows Then
tempList = New MemberList
While myReader.Read
tempList.Add(FillDataRecord(myReader))
End While
End If
myReader.Close()
Finally
CType(myReader, IDisposable).Dispose()
End Try
Finally
CType(myConnection, IDisposable).Dispose()
End Try
Return tempList
End Function