[英]Could not be set to a Double value, non-null value of type Single
我有一个尝试解决的问题,但仍然找不到解决该问题的方法。 当我运行程序时,消息抛出如下
无法将'tblssscr'的'fldscr1'属性设置为'Double'值。 您必须将此属性设置为“ Single”类型的非空值。
这是运行我的项目的班级:
public class tblssscr
{
[Key]
public int tblssscrId { get; set; }
[DisplayName("Request code")]
public int fldssrid { get; set; }
[DisplayName("StudentId")]
public int tblss_studentId { get; set; }
public virtual tblss_student tblss_student { get; set; }
[DisplayName("Student Tempcode")]
public string fldstdtmpcode { get; set; }
[DisplayName("Attandence")]
public int fldatt { get; set; }
[DisplayName("Discount (%)")]
public int flddiscount { get; set; }
[Required(ErrorMessage = "Score 1 is required!")]
[DisplayName("Score 1")]
public float? fldscr1 { get; set; }
[DisplayName("Score 2")]
public float fldscr2 { get; set; }
[DisplayName("Total Score")]
public float fldtscr { get; set; }
[DisplayName("Offer Code")]
public int fldrst { get; set; }
}
如果要在fldscr1
存储一个double, fldscr1
设置为double像这样
[Required(ErrorMessage = "Score 1 is required!")]
[DisplayName("Score 1")]
public double fldscr1 { get; set; }
更改此行:
[DisplayName("Score 1")]
public float? fldscr1 { get; set; }
至:
[DisplayName("Score 1")]
public float fldscr1 { get; set; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.