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

set default value for custom resource

1 Answer 173 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 21 Jan 2008, 04:59 PM
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

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 22 Jan 2008, 03:55 PM
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
Tags
Scheduler
Asked by
Jeff
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or