我试图为它解决近 4 个小时,但我找不到任何解决方案
public class FinalClassScoreModel
{
private readonly FinalClassScore _finalClassScore;
public FinalClassScoreModel(FinalClassScore finalClassScore)
{
this._finalClassScore = finalClassScore;
}
public int EnrollId
{
get
{
return this._finalClassScore.EnrollId;
}
}
public string StudentNo
{
get
{
return this._finalClassScore.Enroll.Student.StudentNo;
}
}
public string ReversedName
{
get
{
return this._finalClassScore.Enroll.Student.ReversedName;
}
}
public decimal? Prelim
{
get
{
return this._finalClassScore.Prelim;
}
}
public string PrelimE
{
get
{
return this._finalClassScore.PrelimE;
}
}
public decimal? Midterm
{
get
{
return this._finalClassScore.Midterm;
}
}
public string MidtermE
{
get
{
return this._finalClassScore.MidtermE;
}
}
public decimal? Final
{
get
{
return this._finalClassScore.Final;
}
}
public string FinalE
{
get
{
return this._finalClassScore.FinalE;
}
}
public decimal? FinalGrade
{
get
{
return this._finalClassScore.FinalGrade;
}
}
public bool IsDropped
{
get
{
return this._finalClassScore.Enroll.IsDropped;
}
}
public bool IsIncomplete
{
get
{
return this._finalClassScore.Enroll.IsIncomplete;
}
}
public bool IsGradeSubmitted
{
get
{
return this._finalClassScore.Enroll.IsGradeSubmitted;
}
}
Public Property FinalClassScoreModels() As IEnumerable(Of FinalClassScoreModel) Implements IAlternativeView.FinalClassScoreModels
Get
Return Me._finalClassScoreModels
End Get
Set(ByVal value As IEnumerable(Of FinalClassScoreModel))
If DesignMode Then Exit Property
Me._finalClassScoreModels = value
Me.dgrAlternativeGrades.DataSource = Me._finalClassScoreModels
End Set
End Property
起初还可以,但是当我删除 FinalClassScoreModelList 上的 1 个数据并重新运行时,它Me.dgrAlternativeGrades.Datasource = Me._finalClassScoreModels
会抛出nullreference exception
public string StudentNo
{
get
{
return this._finalClassScore.Enroll.Student.StudentNo;
}
}
顺便说一句,如果我没有设置datapropertyname
每列的,它不会出错,datagridview
但我需要设置它,因为我不想自动生成列。
我的项目是 vb.net 和 C# 的组合