Telerik RadScheduler 数据源

发布于 2024-12-16 20:55:20 字数 593 浏览 3 评论 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 ,但它不起作用。

I have the ff code:

// 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);
}

Is there a way to bind the entries directly to radScheduler without using foreach statement?

I've also tried using radScheduler.datasource but it doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不会写诗 2024-12-23 20:55:20

请检查以下代码:

.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-struct.html

它在我这边工作。

Please check below code :

.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

It worked from my side.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文