在Calendar控件里绑定的checkbox控件事件怎么不行了
    public CheckBox CreateCheckBox()
    {
        CheckBox chk = new CheckBox();
        chk.ID = "newcheckbox";
        chk.Checked = true;
        chk.BorderColor = System.Drawing.Color.BlueViolet;
        chk.AutoPostBack = true;
        chk.CheckedChanged += new EventHandler(chk_Changed); 
        return chk;
    }    public void chk_Changed(Object sender, EventArgs e)
    {
        Response.Write("<script language=javascript>alert(\"ffgfg\")</" + "script>");
    }    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        DateTime myAppointment = new DateTime(2007, 5, 24);
        if (e.Day.Date == myAppointment)
        {
            e.Cell.Controls.RemoveAt(0);
            e.Cell.Controls.Add(CreateCheckBox());
        }
        else
        {
            e.Day.IsSelectable = false;
        }
    }

解决方案 »

  1.   

    把ispostback里的内容帖出来,有可能是你回发后动态绑定的时间给丢了。
      

  2.   

    把ispostback里的内容帖出来,有可能是你回发后动态绑定的事件给丢了。
      

  3.   

    楼上的楼上说的对,你把Page_Load贴出来看下
      

  4.   

    回滚要加上啊!
      if(!isPostback)
      

  5.   

    我知道回滚啊,但是现在根本就没有绑定到checkchanged事件啊
      

  6.   

    把Page_Load看下啊,不看怎么知道
      

  7.   

    是没有触发 checkchange事件吧
      

  8.   

    同意,先看看ispostback中的东西再说
      

  9.   

    aspx:
    <asp:Calendar ID="Calendar1" runat="server" OnDayRender="Calendar1_DayRender"></asp:Calendar>cs:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {    }    public CheckBox CreateCheckBox()
        {
            CheckBox chk = new CheckBox();
            chk.ID = "newcheckbox";
            chk.Checked = true;
            chk.BorderColor = System.Drawing.Color.BlueViolet;
            chk.AutoPostBack = true;
            chk.CheckedChanged += new EventHandler(chk_Changed); 
            return chk;
        }    public void chk_Changed(Object sender, EventArgs e)
        {
            Response.Write("<script language=javascript>alert(\"ffgfg\")</" + "script>");
        }    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
        {
            DateTime myAppointment = new DateTime(2007, 5, 24);
            if (e.Day.Date == myAppointment)
            {
                e.Cell.Controls.RemoveAt(0);
                e.Cell.Controls.Add(CreateCheckBox());
            }
            else
            {
                e.Day.IsSelectable = false;
            }
        }
    }
      

  10.   

    顶!~~
    在calendar控件里就不行,在其他控件就行啊,到底什么原因啊
      

  11.   

    lz
    我没有试过
    不过在datagrid里面做过类似的做过
    如果在后台的话用foreach绑定事件试一试
      

  12.   

    或者你把那个时间的public
    改为 protected 试一试