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

Get Current Resource

1 Answer 36 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Rolando
Top achievements
Rank 1
Rolando asked on 20 Oct 2010, 01:23 AM
Hi,

How Can I do to Obtain in the code behind the Resource of the appointment when I adding an appointment???

I have this code:

    protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
    {
        string mSubject = e.Appointment.Subject;
        DateTime mStart = e.Appointment.Start;
        DateTime mEnd = e.Appointment.End;
        string mResource = e.Appointment.??????????????????;
    }

I have this code to populate my schedule:

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) ();
    }

void cargarSalones()
    {
        DataSet ds = new DataSet();
        DataTable dtSalones = new DataTable("salones");
        DataTable dtDetalle = new DataTable("detalle");
        
        dtSalones.Columns.Add(new DataColumn("salon", typeof(System.Int32)));
        dtSalones.Columns.Add(new DataColumn("nombre", typeof(System.String)));

        dtDetalle.Columns.Add(new DataColumn("salon", typeof(System.Int32)));
        dtDetalle.Columns.Add(new DataColumn("asunto", typeof(System.String)));
        dtDetalle.Columns.Add(new DataColumn("inicio", typeof(System.DateTime)));
        dtDetalle.Columns.Add(new DataColumn("fin", typeof(System.DateTime)));

        DataRow row = dtSalones.NewRow();
        row["salon"] = 1;
        row["nombre"] = "Salon 101";
        dtSalones.Rows.Add(row);

        DataRow row2 = dtSalones.NewRow();
        row2["salon"] = 2;
        row2["nombre"] = "Salon 202";
        dtSalones.Rows.Add(row2);
        
        DataRow row3 = dtDetalle.NewRow();
        row3["salon"] = 1;
        row3["asunto"] = "Curso A101 - Carrera LAE";
        row3["inicio"] = "08:00";
        row3["fin"] = "08:59";
        dtDetalle.Rows.Add(row3);

        DataRow row4 = dtDetalle.NewRow();
        row4["salon"] = 2;
        row4["asunto"] = "Curso B02 - Carrera II";
        row4["inicio"] = "10:00";
        row4["fin"] = "10:59";
        dtDetalle.Rows.Add(row4);

        ds.Tables.Add(dtSalones);
        ds.Tables.Add(dtDetalle);

        for (int ii = 0; ii < ds.Tables["salones"].Rows.Count; ii++)
        {
            ResourceType salon = new ResourceType();
            salon.KeyField = Convert.ToString(ds.Tables["salones"].Rows[ii]["salon"]);
            salon.Name = Convert.ToString(ds.Tables["salones"].Rows[ii]["nombre"]);
            RadScheduler1.ResourceTypes.Add(salon);
        }

        RadScheduler1.DataSource = ds;
        RadScheduler1.DataMember = "detalle";
        RadScheduler1.DataKeyField = "salon";
        RadScheduler1.DataSubjectField = "asunto";
        RadScheduler1.DataStartField = "inicio";
        RadScheduler1.DataEndField = "fin";
        RadScheduler1.DataDescriptionField = "asunto";
    }

Thanks in Advance.

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 22 Oct 2010, 04:56 PM
Hi Rolando,

Please, refer to the Defining Resources demo and the Database structure help topic. To get a resource from code behind, you can use the following code:

e.Appointment.Resources.GetResourceByType("User")

where "User" is the resource type name.


Greetings,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Rolando
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or