It's quite simple. Think of it!
Imagine, you have grid which is binded with DataTable. All what you need to do is to define starting date and ending date. Then you have to loop through 7 days. How? Please see:
CultureInfo myCi = CultureInfo.CurrentCulture;
Calendar myCal = myCi.Calendar;
CalendarWeekRule myCWR = myCi.DateTimeFormat.CalendarWeekRule;
DateTime firstMonday = new DateTime(DateTime.Today.Year, 1, 1, myCal);
firstMonday = firstMonday.AddDays(-(int)firstMonday.DayOfWeek + (int)DayOfWeek.Monday);
DateTime startDate = myCal.AddWeeks(firstMonday, 38);
DateTime endDate = myCal.AddYears(startDate, 1);
endDate = myCal.AddWeeks(endDate, -1);
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("EmpName", typeof(string)));
firstMonday = startDate;
while(firstMonday<endDate)
{
dt.Columns.Add(new DataColumn(firstMonday.ToString("dd MMM yyyy", myCi), typeof(string)));
firstMonday = firstMonday.AddDays(7);
}
dt.Rows.Add("Maciej Los");
For further details, please see:
How to: Extract the Day of the Week from a Specific Date | Microsoft Docs[
^]
Calendar.AddWeeks Method (DateTime, Int32) (System.Globalization)[
^]