我從列表數據庫中檢索整個數據現在我有四個類,如:我在顯示成員值中出現錯誤,如何解決此問題? ?
Student類:
public class StudentTable
{
public string StudentID { get; set; }
public string StudentName { get; set; }
public StudentTable()
{
}
public StudentTable(string aStudentID, string aStudentName)
{
StudentID = aStudentID;
StudentName = aStudentName;
}
}
課程班
public class CourseTable
{
public string CourseID { get; set; }
public string CourseName { get; set; }
public int Credits { get; set; }
public CourseTable()
{
}
public CourseTable(string aCourseID, string aCourseName, int aCredits)
{
CourseID = aCourseID;
CourseName = aCourseName;
Credits = aCredits;
}
}
招生類
public class Enrollment
{
public StudentTable StudentData { get; set; }
public CourseTable CourseData { get; set; }
public DateTime DOE { get; set; }
public Enrollment()
{
}
public Enrollment(StudentTable aStudentData, CourseTable aCourseData, DateTime aDOE)
{
StudentData = aStudentData;
CourseData = aCourseData;
DOE = aDOE;
}
}
StudentScore分類:
public class StudentScore
{
public Enrollment EnrollmentData { get; set; }
public int Score { get; set; }
public StudentScore()
{
}
public StudentScore(Enrollment aEnrollmentData, int aScore)
{
EnrollmentData = aEnrollmentData;
Score = aScore;
}
}
和我通過查詢從數據庫中檢索數據現在我想顯示StudentID從列表中,但在StudentScore類中我有EnorllmentData不StudentID。
try
{
var aStudentScore = EnrollmentDB.GetAllScore();
comboBox3.DataSource = aStudentScore;
comboBox3.DisplayMember = "StudentID";
comboBox3.ValueMember = "CourseID";
//comboBox3.ValueMember = "Score";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
}
它告訴我一個DisplayMember錯誤,您可以請幫我解決這個問題,在becaouse類StudentScore沒有StudentID變量,這樣我怎麼能顯示從StudentScore類StudentID?
「它向我展示了一個DisplayMember錯誤」 - 你能更精確嗎?*總是*在問題中給出錯誤信息。 – 2012-08-10 20:11:18
您是否將C#重寫爲VB.NET?你在C#,VB.NET或兩者中都有錯誤嗎?什麼是錯誤? – abatishchev 2012-08-10 20:12:29