我正在尝试创建一个选择DateFrom
和DateTo
DateFrom
我需要从to遍历DateTo
并在日历中显示所有这些日期,到目前为止我的代码只选择DateFrom
andDateTo
并将它们作为标签显示在日历中:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
DateTime df = (DateTime)dr.Field<DateTime?>("DateFrom");
DateTime dt = (DateTime)dr.Field<DateTime?>("DateTo");
if (e.Day.Date == dt.Date)
{
Label lbl = new Label();
lbl.BackColor = System.Drawing.Color.Gray;
lbl.Text = "Booked From";
e.Cell.Controls.Add(lbl);
}
if (e.Day.Date == df.Date)
{
Label lbl = new Label();
lbl.BackColor = System.Drawing.Color.Gray;
lbl.Text = "Booked To";
e.Cell.Controls.Add(lbl);
}
}