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;
}
}