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 に答える