protected void btnAdd_Click(object sender, EventArgs e) { lblError.Visible = false; if (infoIsValid()) { if (timeTableDT == null) { timeTableDT = new AdministrationEDSC.ActivityScheduleGridDTDataTable(); } ScheduleDT = getTimetable(false); AdministrationEDSC.ActivityScheduleGridDTRow dr = timeTableDT.NewActivityScheduleGridDTRow(); if (txtEndDate.Text == "") { lblError.Text = "* Required"; txtEndDate.Focus(); } else { var aSched = getTimetableInput(); ScheduleDT.AddActivityScheduleDTRow(aSched); SetScheduleDataSource(); SetTimetableDataSource(); SetTimetablePreview(); btnAdd.Text = "Add another timetable"; } } else { lblError.Visible = true; } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drView = e.Row.DataItem as DataRowView; AdministrationEDSC.ActivityScheduleGridDTRow dr = drView.Row as AdministrationEDSC.ActivityScheduleGridDTRow; Label lblDay = e.Row.FindControl("lblDay") as Label; Label lblTime = e.Row.FindControl("lblTime") as Label; Label lblDate = e.Row.FindControl("lblDate") as Label; if (dr.StartDateTime.Date == dr.EndDateTime.Date) { lblDate.Text = dr.StartDateTime.Date.ToShortDateString(); } else { lblDate.Text = dr.StartDateTime.Date.ToShortDateString() + " - " + dr.EndDateTime.Date.ToShortDateString(); } lblDay.Text = dr.StartDateTime.DayOfWeek.ToString(); lblTime.Text = dr.StartDateTime.ToShortTimeString() + " - " + dr.EndDateTime.ToShortTimeString(); } }