DayPilot Forums

DayPilot is the best open-source Outlook-like calendar control for ASP.NET.
DayPilot Pro Demo (Calendar control)
» DayPilot Pro live demo (Calendar control)
DayPilot Pro Demo (Scheduler control)
» DayPilot Pro live demo (Scheduler control)
Home » How To » Resources - Can I get them from a sqldata source or do I have to programatically add them?

Resources - Can I get them from a sqldata source or do I have to programatically add them?

Hi,

I'm developing a hire application and am using the trial version of DayPilotScheduler.

I am having difficultly getting Resource data into the Scheduler.Do I HAVE to programatically add Resources or is there a simpler method? i.e. can I just extract them from a sqldataadapter?

Any sample code?

thanks

John - 5/31/2008 12:51:43 AM
You should fill the Resources collection manually:
protected void Page_Load(object sender, EventArgs e)
{
// I assume that resources are loaded in dtResources DataTable
foreach (DataRow dr in dtResources.Rows) {
DayPilotScheduler1.Resources.Add(new Resource(dr["name"], dr["id"]);
}
}

The Resources collection is stored in the ViewState so it's possible to place this init code inside if (!IsPostBack) block. However, the ViewState for DayPilotScheduler is usually very large - I recommend turning it off and placing the initialization code outside of if (!IsPostBack).
Dan Letecky - 6/1/2008 10:08:13 PM
Do you mean that it is best to turn off the view state for the scheduler control?
John - 6/1/2008 11:10:40 PM
Yes:
  1. It stores all the events. That is convenient sometimes (you don't have to rebind after CallBack/PostBack) but it means that all events are sent twice to the client (once inside ViewState and once in JSON object). But what's worse, it's also sent back with all requests (PostBacks/CallBacks).
  2. It's not necessary to turn ViewState off until you see the slowdown. But it's the first thing you can do to improve performance.
Dan Letecky - 6/2/2008 7:29:46 AM
Post reply