如何在Button Click事件中执行dayrender事件?

时间:2015-03-23 10:56:51

标签: c# calendar

我正在使用dayrender事件开发一个事件caleneder。我有一个下拉选择月份和另一个下拉选择年份。我需要按照查询结果获取日历。现在,当我按照今天的日期运行程序日历显示数据时。如何将其设置为仅显示选定月份和年份的数据? 我的代码是

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
  e.Cell.BackColor = System.Drawing.Color.Aqua;
  DateTime date = e.Day.Date;
  string day = date.Day.ToString();
  string abc = date.ToString("yyyy/MM/dd");     
  SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
  string command = "select s.Shiftname from ShiftType s,ShiftAllocation a where s.ShiftID=a.ShiftID and  a.Date= '" + abc + "' and Month='" + ddmonth.SelectedItem.Value + "' and Year='" + ddyear.SelectedItem.Text + "'";
  SqlCommand cmd1 = new SqlCommand(command, conn);
  SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
  DataSet ds3 = new DataSet();
  sda1.Fill(ds3);
  var rows1 = ds3.Tables[0].Rows;
  foreach (DataRow row1 in rows1)
  {
    string shift = Convert.ToString(row1["Shiftname"]);
    e.Cell.Text = e.Cell.Text + day;
    e.Cell.Text = e.Cell.Text + shift;
  }
}
protected void Button1_Click(object sender, EventArgs e)
{

}

我需要dayrender功能才能选择月份和年份(仅在按钮点击后)。有人请帮帮我

0 个答案:

没有答案