locked
Caldayrender Event with Range of Dates in a Loop RRS feed

  • Question

  • User-1269860422 posted

     Guys, I am trying to get my calendar to render with all the dates in my database, using ranges.  Only problem is, I got it working fine, but it has shifted everything one day to the future.  Can someone look at my code and tell me where the issue is?

    Thanks!

     

    Protected Sub CalDayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs) Handles Calendar1.DayRender
            Dim strConn As String = ConfigurationManager.ConnectionStrings("SiteDataConnString").ConnectionString
            Dim strQuery As String = "SELECT [EDATESTART], [EDATEEND], [ENAME] FROM [EVENTS_FORM] WHERE [EACTIVE] = 'Yes'" '"SELECT * FROM [events]"
            Dim brdMtngAdapter As SqlDataAdapter = New SqlDataAdapter(strQuery, strConn)
            Dim dsEvents As DataSet = New DataSet()
            brdMtngAdapter.Fill(dsEvents, "events")
            Dim dr As DataRow
    
            For Each dr In dsEvents.Tables(0).Rows
                Dim dtStart As DateTime = CType(dr("EDATESTART"), DateTime)
                Dim dtEnd As DateTime = CType(dr("EDATEEND"), DateTime)
                Dim dtLoop As DateTime = dtStart
                While dtLoop <= dtEnd
                    dtLoop = dtLoop.AddDays(1)
                    Calendar1.SelectedDates.Add(dtLoop)
    
                End While
            Next
    End Sub


     

    Thursday, September 17, 2009 2:09 PM

Answers

  • User-1360095595 posted

    Not sure I fully understood your code, but maybe try switching the two lines of code inside your while loop:

    Calendar1.SelectedDates.Add(dtLoop)
    dtLoop = dtLoop.AddDays(1)

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 18, 2009 6:24 AM

All replies

  • User-1360095595 posted

    Not sure I fully understood your code, but maybe try switching the two lines of code inside your while loop:

    Calendar1.SelectedDates.Add(dtLoop)
    dtLoop = dtLoop.AddDays(1)

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 18, 2009 6:24 AM
  • User-1269860422 posted

     How simple and awesome was that fix, you rock man.  Thanks!

    Friday, September 18, 2009 8:14 AM