Here are my classes:
public class Type_WorkSched
{
public string EmployeeID { get; set; }
public string RecordID { get; set; }
public Type_Schedule[] Schedule { get; set; }
}
public class Type_Schedule
{
public string Days { get; set; }
public string TimeIn_AM { get; set; }
public string TimeOut_AM { get; set; }
public string TimeIn_PM { get; set; }
public string TimeOut_PM { get; set; }
}
I want to store an array of MySchedule
into an object MyWorkSched
.
But I get only the last value of the array.
GV_WorkSched
is the name of the datagrid.
Type_Schedule[] MySchedule = new Type_Schedule[GV_WorkSched.RowCount-1];
Type_WorkSched MyWorkSched = new Type_WorkSched();
MyWorkSched.EmployeeID = Txt_EmployeeID.Text;
MyWorkSched.RecordID = Txt_RecordNumber.Text;
for (int i = 0; i < GV_WorkSched.RowCount-1; i++)
{
MySchedule[i] = new Type_Schedule();
MySchedule[i].Days = Convert.ToString(GV_WorkSched.GetRowCellDisplayText(i, "Days"));
MySchedule[i].TimeIn_AM = Convert.ToString(GV_WorkSched.GetRowCellDisplayText(i, "TimeIn_AM"));
MySchedule[i].TimeOut_AM = Convert.ToString(GV_WorkSched.GetRowCellDisplayText(i, "TimeOut_AM"));
MySchedule[i].TimeIn_PM = Convert.ToString(GV_WorkSched.GetRowCellDisplayText(i, "TimeIn_PM"));
MySchedule[i].TimeOut_PM = Convert.ToString(GV_WorkSched.GetRowCellDisplayText(i, "TimeOut_PM"));
MyWorkSched.Schedule = new Type_Schedule[] { MySchedule[i] };
}
Or is there another way to do it?