This is a migrated thread and some comments may be shown as answers.

[Solved] Resource info not being passed?

3 Answers 140 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 23 Jun 2008, 08:26 PM
I have some resources defined and they show up fine on the Advanced Insert form. Then, after clicking insert, the data doesn't seem to get passed. That, or I'm accessing it wrong. I'm using a custom data source for both Appointments and Resources (DataSet from an XML file). When modifying, it does work, however.

I simply have:

protected void scheduler_AppointmentInsert(Object sender, SchedulerCancelEventArgs e) 
    Response.Write(e.Appointment.Resources.Count.ToString()); // Is always 0 
 
protected void scheduler_AppointmentUpdate(Object sender, AppointmentUpdateEventArgs e) 
    Response.Write(e.ModifiedAppointment.Resources.Count.ToString()); // Is correct 

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 24 Jun 2008, 01:40 PM
Hello Brian,

This looks like a data-binding issue, but we will need to take a look at the code related to binding the scheduler to be sure.

Also, you can use the "Bind to generic list" example as a reference implementation.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brian
Top achievements
Rank 1
answered on 24 Jun 2008, 01:48 PM
private void Page_Load(object sender, EventArgs e) 
    if (!IsPostBack) 
        Session.Remove(AppointmentsKey); 
 
    ResourceType rt = new ResourceType("Room"); 
    rt.DataSource = Rooms
    rt.KeyField = "RoomNo"
    rt.ForeignKeyField = "RoomNo"
    rt.TextField = "RoomName"
    scheduler.ResourceTypes.Add(rt); 
    scheduler.DataSource = Appointments
 
private DataSet Rooms 
    get 
    {        
        DataSet sessRooms = Session[RoomsKey] as DataSet; 
        if (sessRooms == null) 
        { 
            sessRooms = new DataSet(); 
            sessRooms.ReadXml(Server.MapPath("resources.xml")); 
            Session[RoomsKey] = sessRooms; 
        } 
        return sessRooms; 
    } 
 
private DataSet Appointments 
    get 
    { 
         
        DataSet sessApts = Session[AppointmentsKey] as DataSet; 
        if (sessApts == null) 
        { 
            sessApts = new DataSet(); 
            sessApts.ReadXml(Server.MapPath("appointments.xml")); 
            sessApts.Tables[0].PrimaryKey = new DataColumn[]{ sessApts.Tables[0].Columns[0] }; 
            Session[AppointmentsKey] = sessApts; 
        } 
        return sessApts; 
    } 
 
 
<TELERIK:RadScheduler runat="server" ID="scheduler"  
    TimelineView-UserSelectable="false" SelectedView="MonthView" Skin="Web20" 
    OverflowBehavior="Expand" EnableViewState="true" 
    MonthVisibleAppointmentsPerDay="2" OnAppointmentInsert="scheduler_AppointmentInsert" 
    DataKeyField="ID" DataSubjectField="Subject" 
    DataStartField="Start" DataEndField="End" 
    DataRecurrenceParentKeyField="RecurrenceParentID" DataRecurrenceField="RecurrenceRule" 
    OnAppointmentCommand="scheduler_AppointmentCommand" OnAppointmentUpdate="scheduler_AppointmentUpdate" 
    OnAppointmentDelete="scheduler_AppointmentDelete" EnableResourceEditing="true"  
    OnAppointmentCreated="scheduler_AppointmentCreated" 
> 

0
T. Tsonev
Telerik team
answered on 24 Jun 2008, 04:13 PM
Hello Brian,

I have tested the code you have sent me and it gives me an error on postback, as you are trying to add the "Room" resource type for a second time. I have changed the code that initializes the resources to only execute on initial load and everything started working as expecting.

private void Page_Load(object sender, EventArgs e)  
{  
    if (!IsPostBack)  
    { 
        Session.Remove(AppointmentsKey);  
         
        ResourceType rt = new ResourceType("Room");  
        rt.DataSource = Rooms;  
        rt.KeyField = "RoomNo";  
        rt.ForeignKeyField = "RoomNo";  
        rt.TextField = "RoomName";  
        scheduler.ResourceTypes.Add(rt);  
    } 
 
    scheduler.DataSource = Appointments;  
}  

If this does not help, can you please send us a running project? This way we can be sure that we are looking at the same thing.

Best wishes,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
Brian
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Brian
Top achievements
Rank 1
Share this question
or