如何将我的数据库事件绑定到asp.net中的bootstrap日历控件

时间:2015-03-20 07:31:02

标签: c# jquery asp.net twitter-bootstrap events

我是asp.net c#am的新手,使用bootstrap日历控件。 我想使用日历控件通过使用jQuery和Ajax在日历的每一天显示学生生日信息。我的数据库结构看起来像

学生姓名,出生日期,说明等

我已根据出生日期和日历日期访问要在日历上绑定的单月数据。 但是我无法绑定它,任何帮助都会被欣赏。

我的代码是

 if (!IsPostBack)
    {
        DateTime dDate;
        if (Request["SpecificMonth"] != null)
            dDate = Convert.ToDateTime(Request["SpecificMonth"]);
        else
            dDate = DateTime.Now;
        //-------------------DATABASase Events----------------
        MenuEntity ObjMenuEntity = new MenuEntity();
        ObjMenuEntity.LocationId = 2;
        ObjMenuEntity.Fromdate = Convert.ToDateTime("03-01-2015");
        ObjMenuEntity.Todate = Convert.ToDateTime("03-30-2015");
        DataSet dsBindEvent = new DataSet();
        dsBindEvent = MenuEntity.fnBindCalenderEvent(ObjMenuEntity);
        string count = dsBindEvent.Tables[0].Rows.Count.ToString();
        //--------------------Event End--------------------------
        DataTable dtEvents = new DataTable();
        dtEvents = dsBindEvent.Tables[0];
        DataTable datatable = new DataTable();
        datatable.Columns.Add("Day"); //day contains day of the month
        datatable.Columns.Add("Data"); //run time produce html & just place on it.
        datatable.Columns.Add("Title");
        DataRow oRow;
        for (int i = 1; i <= DateTime.DaysInMonth(dDate.Year, dDate.Month); i++)
        {
            DateTime dCalendarDay = new DateTime(dDate.Year, dDate.Month, i);
            oRow = datatable.NewRow(); // here i am preparing data for a specific day. 
            if (!bWorkingDay(dCalendarDay))
            {
                oRow["Data"] = i.ToString() + "<br/><div style='color:Olive'>" + dCalendarDay.ToString("ddd") + " " + getEvents(dCalendarDay, dtEvents);
                oRow["Title"] = "SCMC";
            }
            else
                oRow["Data"] = i.ToString() + "<br/><div style='color:Red'>" + dCalendarDay.ToString("ddd") + " " + getEvents(dCalendarDay, dtEvents);
            datatable.Rows.Add(oRow);
        }

        dlCalendar.DataSource = datatable;
        dlCalendar.DataBind();

        // here just i am making current date block. 
        if (dDate.Year == DateTime.Now.Year && dDate.Month == DateTime.Now.Month)
        {
            foreach (DataListItem oItem in dlCalendar.Items)
            {
                if (oItem.ItemIndex == DateTime.Now.Day - 1)
                {
                    oItem.BorderStyle = BorderStyle.Solid;
                    oItem.BorderColor = System.Drawing.Color.DeepSkyBlue; oItem.BorderWidth = 2;
                }// if closed 
            }// for closed
        }// if closed

    }

我通过另一种方式绑定事件,但它无法正常工作

0 个答案:

没有答案