将int绑定到CheckBox的方法二则

方法1:

<asp:CheckBox id=EditApproved runat="server" Enabled="False" Checked='<%# NumToBool(int.Parse(DataBinder.Eval(Container.DataItem,"approved").ToString())) %>'>

  public bool NumToBool(int approvedState)
  {
   if(approvedState==1)
    return true;
   else
    return false;
  }

方法2:

<asp:CheckBox id=EditApproved runat="server" Enabled="False" Checked='<%# Convert.ToBoolean(DataBinder.Eval(Container.DataItem,"approved")) %>'>

你可能感兴趣的:(checkbox)