var RowsList = new List<PersonelCardClass>(); for (int i = 0; i < dataGridView1.MasterTemplate.Rows.Count-1; i++) { var row=dataGridView1.Rows[i]; //current row RowsList.Add(new PersonelCardClass() //assign cells to one object for every row { carddate = row.Cells[0].Value== null ? "": row.Cells[0].Value, //row:i,culumn0 reward = row.Cells[1].Value == null ? "" : row.Cells[1].Value, //row:i,culumn1 penalti = row.Cells[2].Value== null ? "" : row.Cells[2].Value, //row:i,column2 vacationHours = row.Cells[3].Value== "" ?"00:00" :row.Cells[3].Value, //row:i,column3 overTimeHours = row.Cells[4].Value== "" ? "00:00": row.Cells[4].Value, //row:i,column4 workHours = row.Cells[5].Value== "" ? "00:00":row.Cells[5].Value, //row:i,column5 mrnngEntranceTime = row.Cells[6].Value== "" ? "00:00": new row.Cells[6].Value //rowi,column6 } ); } return RowsList; //return collection of objects
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)