search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How Do I Export A Calendar With Events Populated From a DB?

Asked by Nick
11 years ago.

I have a DayPilot Calendar, populated with events from a DataSource, that I am trying to export WITH the events. When I run the following export, I get the correct calendar but it has no events:

Response.Clear()
Response.ContentType = "image/png"
Dim img As System.IO.MemoryStream = DP_MonthCalendar.Export(System.Drawing.Imaging.ImageFormat.Png)
img.WriteTo(Response.OutputStream)
Response.End()

This code is ran by clicking a linkbutton below the fully populated DayPilot Calendar. Am I missing a setting or property that will populate events on export?

Answer posted by Dan Letecky [DayPilot]
11 years ago.

You should load the events before calling Export:

DP_MonthCalendar.DataSource = yourDataTable
DP_MonthCalendar.DataBind()
Dim img As System.IO.MemoryStream = DP_MonthCalendar.Export(System.Drawing.Imaging.ImageFormat.Png) 
Comment posted by Nick
11 years ago.

Thank you for the reply. I tried that but with no luck.

[CODE]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Clear()
Response.ContentType = "image/png"
DP_MonthCalendar.DataSourceID = "DS_GetCalendarEvents"
DS_GetCalendarEvents.DataBind()
DP_MonthCalendar.DataBind()
Dim img As System.IO.MemoryStream = DP_MonthCalendar.Export(System.Drawing.Imaging.ImageFormat.Png)
img.WriteTo(Response.OutputStream)
Response.End()
End Sub
[/CODE]

The page that is exporting the calendar is a pass-thru. It loads the Calendar from the DB and displays the events, then on page_load it exports itself as an image. When I disable the pass-thru on page load it properly displays the events on the asp Calendar.

I have also tried adding the export functionality to a button and clicking it after the events are all populated. This does not work either. It too prints a blank calendar.

Comment posted by Nick
11 years ago.

I should clerify this:

I am using the "DayPilot Month", not "DayPilot Calendar".

Comment posted by Dan Letecky [DayPilot]
11 years ago.

Does the DS_GetCalendarEvents instance has any select parameters defined (I assume it's SqlDataSource)? Are they set correctly?

You may also try to generate the data set using GetView() (and check the result):

DP_MonthCalendar.DataSource = DS_GetCalendarEvents.GetView(null)
Comment posted by Nick
11 years ago.

AHHHHH! Very Good Dan Letecky!!

It turns out your method worked properly. I had a different bug that was causing events not to populate before it exported.

Problem solved. Thank you very much!

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.