search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to change the column text header name?

Asked by jordjmax
10 years ago.

Since it is only for one day, i would like to display today instead of monday. Attached are my images, there are limited event handler so hope it can be solved.

public partial class number2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstWorkingDayOfWeek(new DateTime(2014, 04, 03));
//DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstWorkingDayOfWeek(DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek).Date);
DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days);
DataBind();
}

}

private DataTable dbGetEvents(DateTime start, int days)
{
string constr = ConfigurationManager.ConnectionStrings["ProjectConnectionString"].ConnectionString;
SqlDataAdapter da = new SqlDataAdapter("SELECT ID, PURPOSE, [START_DATE], [END_DATE], [START_TIME], [END_TIME] FROM [Schedule]", constr);
da.SelectCommand.Parameters.AddWithValue("start", start);
da.SelectCommand.Parameters.AddWithValue("end", start.AddDays(days));
DataTable dt = new DataTable();
da.Fill(dt);

for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["START_DATE"] = CombineDateAndTime(dt.Rows[i]["START_DATE"], dt.Rows[i]["START_TIME"]);
dt.Rows[i]["END_DATE"] = CombineDateAndTime(dt.Rows[i]["END_DATE"], dt.Rows[i]["END_TIME"]);
}

return dt;
}

public static DateTime CombineDateAndTime(object date, object time)
{
if (date == null)
{
// Add some logic for this scenario. Here are 2 examples:
//throw new ArgumentNullException("date");
//date = DateTime.MaxValue;
}
if (time == null)
{
// Add some logic for this scenario.
//throw new ArgumentNullException("time");
//time = 0;
}

DateTime dt = Convert.ToDateTime(date);
float hoursAndMinutes = Convert.ToInt32(time);

return CombineDateAndTime(dt, hoursAndMinutes);
}
public static DateTime CombineDateAndTime(DateTime date, float time)
{
int hours = Convert.ToInt32(Math.Round((decimal)time / 100, MidpointRounding.AwayFromZero));
float remainder = time - (hours * 100);
int minutes = Convert.ToInt32(Math.Round((decimal)remainder, MidpointRounding.AwayFromZero));
DateTime returnDate = date.Date.AddHours(hours).AddMinutes(minutes);
return returnDate;
}
}

Answer posted by Dan Letecky [DayPilot]
10 years ago.

There is no built-in mechanism for customizing the column header in the Lite version. You will have to modify the source code.

Comment posted by Jordjmax
10 years ago.

how do i modify to make the text to (today)? below are my codes. @Dan Letecky

<DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server"
DataStartField="START_DATE"
DataEndField="END_DATE"
DataTextField="Names"
DataValueField="BOOK_SNO"
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; margin-right: 6px;" DayEndsHour="6"
HeaderDateFormat="dddd" StartDate="" CellHeight="40" EventFontSize="17pt"
>
</DayPilot:DayPilotCalendar>

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.