class Choice(models.Model):
choice_text = models.CharField(max_length=100, null=True)
question= models.ForeignKey(Question, null=True , related_name='choices')
is_answer = models.BooleanField(default=False)
objects = ChoiceManager()
def save(self, *args, **kwargs):
if self.question.choices.all().count() > 4:
print "You Shall Not Save"
raise ValueError
else:
print "Super Method Called"
super(Choice, self).save(*args, **kwargs)
当我运行此代码时,它告诉我 int cnt = 1;
public System.Windows.Forms.Label addLabel(string s,int i)
{
System.Windows.Forms.Label l = new System.Windows.Forms.Label();
l.Top = i;
l.Name = ""+cnt;
Controls.Add(l);
cnt++;
return l;
}
接受无效参数,并且它应该采用Control类型的参数。
答案 0 :(得分:3)
我看到你把“asp.net”标记放在你的问题上,因此即使你没有在你的问题中指明,我也认为你正在讨论ASP.NET WebForm。 在这种情况下,您应该参考
System.Web.UI
命名空间(不是System.Windows.Forms),可能在你的情况下返回一个LiteralControl。 我希望这会有所帮助。