C# – How to create a timetable

asp.netcgridviewweb

I have to create a timetable for a web application with the hours as column names and the week days as row names. I mean something like that:


—————| 8:00 | 9:00 | 10:00 | 11:00 | 12:00 | 13:00 |

Monday

Tuesday

Wednesday

Thursday

Friday

I would like to use ASP.NET. I tried using GridView so that I can use it's events and populate the GridView with the data from the database but it is not flexible enough. I can't set the weekdays as row names. I know that it can be done using jQuery but I haven't learnt jQuery and that's why it is very difficult for me to do it this way.
I would appreciate it if someone could help me with this problem.

Best Answer

Declare a DataTable object

DataTable dt = new DataTable();

add DayName column to it
add the timings as columns to it 8:00, 9:00, 10:00, 11:00, 12:00, 13:00 etc

dt.Columns.Add("test");

add 7 rows for each weekday

DataRow dr = dt.NewRow();
dr["DayName"] = "Sunday";
dt.Rows.Add(dr);

DataRow dr2 = dt.NewRow();
dr2["DayName"] = "Monday";
dt.Rows.Add(dr2);

finally bind the DataTable to grid