Answers
下面找吧.有你需要的.正好我也做过.
private void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
{
// if(!Page.IsPostBack)
// {
DateTime dt =new DateTime(1,1,1);
if(this.Calendar1.SelectedDate.CompareTo(dt)==0)
// if(aa== "0 ")
{
dbaAppoint.getHolidayDateSet(ref ds,dateStart,dateEnd,Application[ "OleConn "].ToString());
for(int i = 0;i <ds.Tables[ "table "].Rows.Count;i++)
{
for(int j =14;j <23;j++)
{
if(ds.Tables[ "table "].Rows[i][j].ToString()!= "0 ")
{
try
{
DateTime temp= Convert.ToDateTime(ds.Tables[ "table "].Rows[i][0].ToString()+ "- "+ds.Tables[ "table "].Rows[i][1].ToString().PadLeft(2, '0 ')+ "- "+ds.Tables[ "table "].Rows[i][j].ToString().PadLeft(2, '0 '));
if(e.Day.Date.CompareTo(temp.Date)==0)
{
e.Day.IsSelectable = false;
e.Cell.ForeColor = Color.Red;
// e.Cell.Enabled =false;
}
}
catch
{
}
}
}
}
ds.Clear();
if(e.Day.Date.DayOfWeek.CompareTo(DayOfWeek.Sunday)==0)
{
e.Cell.ForeColor = Color.Red;
}
if(e.Day.Date.AddDays(-1).CompareTo(DateTime.Now) <0)
{
e.Day.IsSelectable = false;
e.Cell.Enabled =false;
}
if(DateTime.Now.AddMonths(1).Date.CompareTo(e.Day.Date) <=0)
{
e.Day.IsSelectable = false;
e.Cell.Enabled =false;
}
if(e.Day.IsOtherMonth==true)
{
e.Day.IsSelectable = false;
}
if(e.Day.IsWeekend==true)
{
e.Day.IsSelectable =false;
}
}
}