Urgent Help Required

7 posts, 1 answers
  1. Sher
    Sher avatar
    12 posts
    Member since:
    Mar 2011

    Posted 11 Mar 2011 Link to this post

    I am a newbie in using telerik controls so my question may be foolish but i am stuch here so i gotta ask.
    i am trying to add appointments into the radscheduler on pageload.....
    but i am getting this error
    'Telerik.Web.UI.AppointmentCollection' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'Telerik.Web.UI.AppointmentCollection' could be found (are you missing a using directive or an assembly reference?)'
    i have referenced Telerik.Web.UI in my page as well as the project....

    the code snippet is as below
    **dr is the object of SqlDataReader

    Appointment ap = new Appointment();
     ap.Subject = dr["Subject"].ToString();
    ap.Start = DateTime.Parse(dr["StartDateTime"].ToString());
    ap.End = DateTime.Parse(dr[""].ToString());
    ap.RecurrenceRule = dr["RecurrenceRule"].ToString();

     this.RadScheduler1.InsertAppointment(ap);   ///Error is on this line...

    Thanks in advance

    Regards,
    Sher


  2. Brian
    Brian avatar
    45 posts
    Member since:
    May 2008

    Posted 11 Mar 2011 Link to this post

    This is just a guess but you're not assigning a value to the ID property of the appointment - ie ap.ID = dr("ID").ToString().

    I think that each appointment needs a subject, start time, end time and ID...

    Brian
  3. Sher
    Sher avatar
    12 posts
    Member since:
    Mar 2011

    Posted 11 Mar 2011 Link to this post

    Thanks for the reply but my problem seems to be with the radScheduler1.Appointments.Add() Function,
    as it is used to add the functions to the appointment collection of the scheduler, it is not working, even the intellisense of VS2010 is not giving the suggestion for this function, i am really blank about that :(
  4. Answer
    Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 12 Mar 2011 Link to this post

    Hi Brian,

    When inserting appointments to the RadScheduler you need to specify the ID, Start, End and Subject of the appointment:

    DateTime start = DateTime.Now.ToUniversalTime();
    DateTime end = start.AddHours(1);
    Appointment apt = new Appointment("1", start, end, "Do it now.");
    RadScheduler1.InsertAppointment(apt);
     
    Best wishes,
    Veronica Milcheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. Sher
    Sher avatar
    12 posts
    Member since:
    Mar 2011

    Posted 15 Mar 2011 Link to this post

    Thanks Veronica, it Works beautifully, but just for the sake of info, can u please tell me why radscheduler1.Appointments.add() is not available to me.


    Thanks and Regards,
    Sher
  6. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 18 Mar 2011 Link to this post

    Hi Sher,

    The reason why you can not add appointments directly to AppointmentsCollection is that internally it implements the IEnumerable interface. IEnumerable<T> does not necessarily represent a collection to which an items can be added. In fact, it does not necessarily represent a collection at all! It only allows you to iterate the collection but not to modify it.

    All the best,
    Veronica Milcheva
    the Telerik team
  7. Sher
    Sher avatar
    12 posts
    Member since:
    Mar 2011

    Posted 18 Mar 2011 Link to this post

    Hi Veronica,

    Thanks for the reply.

    Regards,
    Sher
Back to Top