OracleDataTable dt = PlatypusSchedData.GetAvailablePlatypi();
OracleDataTable outputDt = new OracleDataTable();
int iRows = 12;
while (iRows > 0)
{
outputDt.Rows.Add(new DataRow()); // line 1
//var dr = new DataRow(); // line 2a
//outputDt.Rows.Add(dr); // line 2b
iRows -= 1;
}
for (int i = 0; i < dt.Rows.Count; i += 1) {
DataRow dr = dt.Rows[i];
int outputColumn = 0;
if (i % 12 == 0 && i > 0) {
outputColumn += 1; //2?
}
outputDt.Rows[i % 12][outputColumn] = dr[0];
outputDt.Rows[i % 12][outputColumn + 1] = dr[1];
}
dataGridView1.DataSource = outputDt;
... Tôi nhận được lỗi thời gian biên dịch này bằng cách sử dụng dòng 1 (dòng 2a và 2b nhận xét ra) hoặc sử dụng dòng 2a và 2b (với dòng 1 nhận xét ra):
'System.Data.DataRow.DataRow (System.Data.DataRowBuilder)' là không thể tiếp cận do mức độ bảo vệ của nó
này được baffling tôi vì DataRow trong vòng lặp for được dung thứ. Làm thế nào tôi có thể thêm các DataRows này vào OracleDataTable của tôi?