0

在 c# 中使用 asp.net 我希望能够在日历中的选定日期周围放置边框颜色。我可以在每个单元格周围放置一个边框,但是我希望能够在几个日期周围放置一个边框。

我使用的日历也是工具栏选项(日历控件)中的基本日历。

到目前为止,我用来在一个单元格周围设置边框的代码如下所示:

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
    if (dsHolidays != null)
    {
        foreach (DataRow dr in dsHolidays.Tables[0].Rows)
        {
            DateTime nextDate;
            DateTime endDate;

            nextDate = (DateTime)dr["date"];
            endDate = (DateTime)dr["date1"];

            if (nextDate <= e.Day.Date && endDate >= e.Day.Date)
            {
                e.Cell.BackColor = System.Drawing.Color.Gray;
                e.Cell.BorderColor = System.Drawing.Color.DarkBlue;
                e.Cell.BorderWidth = 4;
                e.Day.IsSelectable = false;
            }
        }
    }
}    
4

0 回答 0