We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load holidays from database into Gantt

Platform: ASP.NET MVC |
Control: Gantt

In Gantt, we can load holidays collection from database by passing holidays collections to view page by using ViewBag. The below code example shows how to load holidays from SQL database into Gantt.


using Syncfusion.JavaScript.Models;
public ActionResult Index()
   ViewBag.holidays = GetHolidayData();
   return View();
public List<Holiday> GetHolidayData()
    List<Holiday> list = new List<Holiday>();
    SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);//connectionString
    using (con)
       using (var command = con.CreateCommand())
          command.CommandText = "SELECT * FROM holidayData";
          using (var reader = command.ExecuteReader())
             var indexOfCol1 = reader.GetOrdinal("Day");
             var indexOfCol2 = reader.GetOrdinal("Background");
             var indexOfCol3 = reader.GetOrdinal("Label");                       
             while (reader.Read())
                Holiday obj = new Holiday();
                obj.Day = reader.GetValue(indexOfCol1).ToString();
                obj.Background= reader.GetValue(indexOfCol2).ToString();
                obj.Label = reader.GetValue(indexOfCol3).ToString();                          
    return list;






Load holidays from database into Gantt.



A simple sample to load holidays from database is available here.


2X faster development

The ultimate ASP.NET MVC UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile