set default value for custom resource

2 posts, 0 answers
  1. Jeff
    Jeff avatar
    33 posts
    Member since:
    Sep 2006

    Posted 21 Jan 2008 Link to this post

    I am trying to insert a new schedule programmatically. When a link is clicked, the scheduler opens in advanced edit form mode with certain items filled in such as subject and time. I am trying to set a custom resource value programmatically as well, for example:

    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
    RadScheduler1.HideEditForm();
    RadScheduler1.Rebind();
    // create the default appointment and times
    Appointment app = new Appointment();
    string sStart = DateTime.Now.ToShortDateString();
    DateTime dStart = DateTime.Parse(sStart);
    dStart = dStart.AddDays(1);
    app.Start = dStart;
    app.End = dStart.AddHours(2);
    string[] subjects = e.CommandArgument.ToString().Split("|".ToCharArray());
    string theSubject = string.Empty;
    for (int i = 0; i < subjects.Length; i++)
    {
    switch (i)
    {
    case 1:
    theSubject = theSubject +
    "Name(s):" + System.Environment.NewLine;
    break;
    case 4:
    theSubject = theSubject +
    "Address:" + System.Environment.NewLine;
    break;
    case 11:
    theSubject = theSubject +
    "Revision: ";
    break;
    default:
    break;
    }
    if (subjects[i].Trim() != "")
    {
    theSubject = theSubject + subjects[i] + System.
    Environment.NewLine;
    .......................
    }
    app.Subject = theSubject;

    app.Attributes["Orders"] = "company";
    RadScheduler1.ShowAdvancedEditForm(app);
    }

    But this does not set teh default drop list box for the custom resource of "Orders". The selected value is "-", and all the possible choices show up.

    How would I go about accomplishing this?

    Thanks,
    Jeff

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 22 Jan 2008 Link to this post

    Hello Jeff,

    Thank you for your question.

    Please, consider the following sample code which shows how to add a resource to an appointment dynamically:

    aspx:
    <ResourceTypes> 
                    <telerik:ResourceType DataSourceID="SqlDataSource2" ForeignKeyField="RoomID" KeyField="ID" 
                        Name="Rooms" TextField="RoomName" /> 
                </ResourceTypes> 

    code-behind:
    protected void Button1_Click(object sender, EventArgs e)  
        {  
            Appointment app = new Appointment();  
            string sStart = DateTime.Now.ToShortDateString();  
            DateTime dStart = DateTime.Parse(sStart);  
            dStart = dStart.AddDays(1);  
            app.Start = dStart;  
            app.End = dStart.AddHours(2);  
            app.Subject = "test";  
     
            Resource r = (Resource) RadScheduler1.Resources.GetResource("Rooms", 1);  
            app.Resources.Add(r);  
     
            RadScheduler1.InsertAppointment(app);   
        } 

    Should you have any other questions, please do not hesitate to contact us.


    All the best,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top