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

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

Asked by John
15 years ago.

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

Comment posted by Dan Letecky
15 years ago.
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).
Comment posted by John
15 years ago.
Do you mean that it is best to turn off the view state for the scheduler control?
Comment posted by Dan Letecky
15 years ago.
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.
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.