简体   繁体   中英

Data Grid View data binding with List

I am facing an issue where I am trying to bind a List of object with three data grid. I got three classes DashboardResultSet, Resultset, DetailResultSet.

DashboardResultSet Class has the following code:

public class DashboardResultSet
{
    public string TestType { get; set; }
    public string SuccessfulExeceution { get; set; }
    public string FailedExeceution { get; set; }
    public string FailedCsvTest { get; set; }
    public int Total { get; set; }

    public BindingList<ResultSet> _ResultSet = new BindingList<ResultSet>();

    public BindingList<ResultSet> ResultSet { get { return _ResultSet; } }
}

ResultSet Class have the same Binding List for DetailResultset. I am populating my objects and adding it to the binding list and then assiging it like that

dashboardResultSetDataGridView.DataSource = dashboardResultSets;
resultSetDataGridView.DataSource = dashboardResultSets;
resultSetDataGridView.DataMember = "ResultSet";
detailResultSetDataGridView.DataSource = dashboardResultSets;
detailResultSetDataGridView.DataMember = "DetailResultSet";// Error Cannot create the Child list

detailResultSetDataGridView is unable to find the dataMember DetailResultSet.

The List hierarchy will be DashBoard is main list which contain the lists of ResultSets and each ResultSets contain List of DetailResultSet. There are three DataGridView. The first two are populating but for the third on I am getting error.

您正在绑定到成员“ DetailResultSet”,但类DashboardResultSet没有此类属性。

How about you could try

detailResultSetDataGridView.DataSource = dashboardResultSets.ResultSet;
detailResultSetDataGridView.DataMember = "DetailResultSet"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM