对于daypilot日历控件,如何在列名称上显示mon到fri而不是date

时间:2014-03-18 00:10:00

标签: c# sql webforms timetable daypilot

enter image description here

enter image description here

目前我的只显示列名称上的日期。我想显示星期一到星期五当然正确的日期。等我想显示mon而不是17/03/2014,我想显示tue而不是18/03/2014等等。碰到了

我的来源

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="number2.aspx.cs" Inherits="number2" %>

<%@ Register assembly="DayPilot" namespace="DayPilot.Web.Ui" tagprefix="DayPilot" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link rel="stylesheet" href="stylesheets/style.css" type="text/css" />
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="text-align: center">

        <asp:Label ID="lblVenue" runat="server" 
            style="font-size: xx-large; font-weight: 700" Text="Label"></asp:Label>

        <daypilot:daypilotcalendar 
     id="DayPilotCalendar1" 
     runat="server" 
     DataStartField="eventstart" 
     DataEndField="eventend"
     DataTextField="name" 
     DataValueField="id" 
     Days="5" 
     OnEventMove="DayPilotCalendar1_EventMove" 
     EventMoveHandling="CallBack" BackColor="#0066FF" BusinessBeginsHour="8" 
            BusinessEndsHour="19" CssOnly="False" EventBackColor="#66FF99" 
            HourBorderColor="Lime" HourHalfBorderColor="#0066FF" 
            HourNameBackColor="#6699FF" HourNameBorderColor="#0066FF" HoverColor="#0066FF" 
            NonBusinessBackColor="#0066FF" style="top: 0px; left: 0px"
     >
    </daypilot:daypilotcalendar>


    </div>
    </form>
</body>
</html>

背后的代码

public partial class number2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        lblVenue.Text = Session["roomvalue"] != null ? Session["roomvalue"].ToString() : "";

        if (!IsPostBack)
        {
            DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstWorkingDayOfWeek(new DateTime(2014, 03, 17));
            DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days);
            DataBind();
        }
    }


        private DataTable dbGetEvents(DateTime start, int days)
    {
        SqlDataAdapter da = new SqlDataAdapter("SELECT [id], [name], [name2], [eventstart], [eventend] FROM [event] WHERE NOT (([eventend] <= @start) OR ([eventstart] >= @end))", ConfigurationManager.ConnectionStrings["projectConnectionString"].ConnectionString);
        da.SelectCommand.Parameters.AddWithValue("start", start);
        da.SelectCommand.Parameters.AddWithValue("end", start.AddDays(days));
        DataTable dt = new DataTable();
        da.Fill(dt);
        return dt;
    }
}

@Xenolightning dun hav你提到的事件

enter image description here

2 个答案:

答案 0 :(得分:1)

查看他们的Online Documentation,您可以订阅一个扩展事件BeforeHeaderRender。您可以在此处更改列标题标签。查看他们的示例here

protected void DayPilotCalendar1_BeforeHeaderRender(object sender, BeforeHeaderRenderEventArgs e)
{
    e.Html += e.Date.ToString('dddd');
}

编辑:

实际解决方案:

将属性DayPilotCalendar.HeaderDateFormat设置为dddd会将其更改为“星期一,星期二......”

答案 1 :(得分:1)

在日历控件中,设置

HeaderDateFormat="dddd"

这将只显示日期名称