protected void GetClassScheduleData() { List <ClassSchedule> schedule = ClassSchedule.GetClassScheduleData(); gridView_Schedule.DataSource = schedule; gridView_Schedule.DataBind(); //removes the default border="1" from the generated grid view gridView_Schedule.GridLines = GridLines.None; //sets cellspacing to zero gridView_Schedule.CellSpacing = 0; }
public static List <ClassSchedule> GetClassScheduleData() { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["class_schedule"].ConnectionString); SqlCommand cmd = new SqlCommand("spClassScheduleDisplay", conn); cmd.CommandType = CommandType.StoredProcedure; List <ClassSchedule> schedule = new List <ClassSchedule>(); try { conn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { ClassSchedule cs = new ClassSchedule(); cs.sectName = rdr["SectionName"].ToString(); cs.synonym = rdr["Synonym"].ToString(); cs.credhrs = Convert.ToInt32(rdr["CreditHrs"]); cs.title = rdr["Title"].ToString(); cs.totalSeats = Convert.ToInt32(rdr["TotalSeats"]); cs.remainSeats = Convert.ToInt32(rdr["RemainingSeats"]); cs.meetInfo = rdr["MeetInformation"].ToString(); cs.room = rdr["Room"].ToString(); cs.days = rdr["Days"].ToString(); cs.startTime = rdr["StartTime"].ToString(); cs.endTime = rdr["EndTime"].ToString(); cs.instFullName = rdr["InstFullName"].ToString(); cs.location = rdr["Location"].ToString(); schedule.Add(cs); } } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { cmd.Dispose(); conn.Close(); } return(schedule); }