0

我有ff代码:

// note: entries is a list binded to a query from the database
//       wherein i'm passing some parameters to satisfy
//       the conditions from the query

foreach (var entry in entries)
{
    Appointment appointment = new Appointment();
    appointment.Start = entry.StartDateTime;
    appointment.End = entry.EndDateTime;
    appointment.Summary = entry.Summary;

    this.radScheduler.Appointments.Add(appointment);
}

有没有办法在radScheduler不使用foreach语句的情况下直接绑定条目?

我也尝试过使用radScheduler.datasource,但它不起作用。

4

1 回答 1

1

请检查以下代码:

.aspx

<telerik:RadScheduler ID="RadScheduler1" runat="server" DataKeyField="ID" DataSubjectField="Subject"
    DataStartField="StartDate" DataEndField="EndDate" >

.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        List<MyScedule> lst = new List<MyScedule>();
        MyScedule obj = new MyScedule();
        obj.ID = 1;
        obj.Subject = "my Subject";
        obj.StartDate = DateTime.Now;
        obj.EndDate = DateTime.Now.AddHours(1);
        lst.Add(obj);

        MyScedule obj1 = new MyScedule();
        obj1.ID = 2;
        obj1.Subject = "my Subject";
        obj1.StartDate = DateTime.Now.AddHours(2);
        obj1.EndDate = DateTime.Now.AddHours(3);
        lst.Add(obj1);

        RadScheduler1.DataSource = lst;
        RadScheduler1.DataBind();
    }
}

。CS

public class MyScedule
{
    public int ID { get; set; }
    public string Subject { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
}

http://www.telerik.com/help/aspnet-ajax/scheduler-database-structure.html

它从我这边工作。

于 2011-11-17T11:18:44.573 回答