[英]Selecting multiple dates across multiple months in the asp calendar
I have encountered the following issue with asp calender. 我遇到了asp压延机的以下问题。
Currently, I am able to select multiple dates within the range (which I have set) which is within 1 month. 目前,我可以在1个月以内的范围(已设置)中选择多个日期。 However I am unable to get the correct selected dates if my range is within 2 months (cross month). 但是,如果我的范围在2个月(跨月)以内,则无法获得正确的所选日期。
Within 2 months: 2个月内:
If my calendar displays at the 1st month, I can still gets the dates from the 2 months but may have duplication dates on the 2nd months. 如果我的日历显示在第一个月,我仍然可以获取两个月的日期,但是第二个月可能有重复的日期。
If my calendar display at the 2nd month, I am only able to get dates from the 2nd month. 如果我的日历显示在第二个月,则只能获取第二个月的日期。
Any advise for the above issue? 对上述问题有什么建议吗? Thanks in advance~ =) 提前谢谢〜=)
protected void CalendarMain_DayRender(object sender, DayRenderEventArgs e)
{
DateTime minDate, maxDate;
if (!tbStartDate.Text.Equals("") && !tbEndDate.Text.Equals(""))
{
minDate = Convert.ToDateTime(tbStartDate.Text);
maxDate = Convert.ToDateTime(tbEndDate.Text);
if (e.Day.Date < minDate || e.Day.Date > maxDate)
{
e.Day.IsSelectable = false;
}
if (e.Day.Date >= minDate && e.Day.Date.Date <= maxDate)
{
e.Cell.BackColor = Color.FromName("#3f97ab");
}
}
DataTable dtgv = Session["dtSelectedDateData"] as DataTable;
if (dtgv != null)
{
foreach (DataRow drr in dtgv.Rows)
{
string DateValue = drr["Time_Start"].ToString();
if (e.Day.Date.ToString("dd/MM/yyyy") == DateValue.Substring(0, 10))
{
e.Cell.ForeColor = System.Drawing.Color.Pink;
e.Day.IsSelectable = false;
}
}
}
if (e.Day.IsSelected == true)
{
PatientsSchedule.listDatetime.Add(e.Day.Date);
}
Session["SelectedDate"] = PatientsSchedule.listDatetime;
}
public static List<DateTime> listDatetime = new List<DateTime>();
I have solved my issues. 我已经解决了我的问题。 Here's the trick, I added a new List<> in my class file and a conditions statement under the calender SelectionChanged. 这是窍门,我在类文件中添加了一个新的List <>,并在压光机SelectionChanged下添加了条件语句。 So it will capture value for every click. 因此,它将捕获每次点击的价值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.