我爱我老婆

扩展CheckBoxFieldPro

CheckBoxField竟然不支持int型的数据

现扩展加上int的支持,如果为0,则不选中,为1,则选中.

代码:

   public class CheckBoxFieldPro : CheckBoxField
    {
        protected override void OnDataBindField(object sender, EventArgs e)
        {
            System.Web.UI.Control control = (System.Web.UI.Control)sender;
            System.Web.UI.Control namingContainer = control.NamingContainer;
            object obj2 = this.GetValue(namingContainer);
            if (obj2 is bool)
            {
                ((CheckBox)control).Checked = (bool)obj2;
            }
            if (obj2 is int)
            {
                ((CheckBox)control).Checked = (int)obj2 == 1 ? true : false;
            }
            ((CheckBox)control).Text = this.Text;
        }
    }

posted @ 2009-04-30 12:15  DataFlow  阅读(190)  评论(0编辑  收藏  举报