Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. 2.0 Calendar populated from database? [modified]

2.0 Calendar populated from database? [modified]

Scheduled Pinned Locked Moved ASP.NET
helpdatabasetutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    munklefish
    wrote on last edited by
    #1

    Hi, Im really struggling to find solutions to my problem so any help would be greatly appreciated! Basically i want to create an events calendar which shows the current month. If the database holds any events for the current month these should be indicated within the calendar control on the corresponding day. I know items can be added to the calendar using the day render event but i dont know how to best use this to get data from the SQLDataAdapter etc. Thanks in advance. -- modified at 8:49 Tuesday 12th September, 2006

    M 1 Reply Last reply
    0
    • M munklefish

      Hi, Im really struggling to find solutions to my problem so any help would be greatly appreciated! Basically i want to create an events calendar which shows the current month. If the database holds any events for the current month these should be indicated within the calendar control on the corresponding day. I know items can be added to the calendar using the day render event but i dont know how to best use this to get data from the SQLDataAdapter etc. Thanks in advance. -- modified at 8:49 Tuesday 12th September, 2006

      M Offline
      M Offline
      mbbisht
      wrote on last edited by
      #2

      you have to create runtime button controls according to the data Fetch from database attach event using delegate. u can populate function corresponding to the day\Date click as button control

      Mahendra

      M 1 Reply Last reply
      0
      • M mbbisht

        you have to create runtime button controls according to the data Fetch from database attach event using delegate. u can populate function corresponding to the day\Date click as button control

        Mahendra

        M Offline
        M Offline
        munklefish
        wrote on last edited by
        #3

        Hi, Thanks for the reply but it makes no sense whatsoever! Please explain.

        L 1 Reply Last reply
        0
        • M munklefish

          Hi, Thanks for the reply but it makes no sense whatsoever! Please explain.

          L Offline
          L Offline
          l0kke
          wrote on last edited by
          #4

          If you just want to display text within day cell, then you can use DayRender method in your own class MyCalendar, which extends Calendar control. class MyCalendar : Calendar { private ArrayList myEvents; public MyCalendar() : base() { DayRender += new DayRenderEventHandler(myCalendar_DayRender); } protected override OnPreRender(object sender, EventArgs e) { DateTime visibleDate = (VisibleDate > new DateTime(2000, 1, 1)) ? VisibleDate : TodaysDate; myEvents = LoadEventsFromDatabase(visibleDate.Month, visibleDate.Year); } void MyCalendar_DayRender(object sender, DayRenderEventArgs e) { for(int i=0; i < myEvents.Count; i++) { if (((MyEvent)myEvents[i]).Date.Day == e.Day.Date.Day) { e.Cell.Controls.Add(new LiteralControl("
          " + ((MyEvent)myEvents[i]).EventTitle); } } } } I suppose you created MyEvent class with two properties, DateTime Date and string EventTitle. And you have a method LoadEventFromDatabase, which queries database, retrieves events and transform them into ArrayList of MyEvent objects (or you can use generic List instead of ArrayList) I hope it works :) Pilo

          M 1 Reply Last reply
          0
          • L l0kke

            If you just want to display text within day cell, then you can use DayRender method in your own class MyCalendar, which extends Calendar control. class MyCalendar : Calendar { private ArrayList myEvents; public MyCalendar() : base() { DayRender += new DayRenderEventHandler(myCalendar_DayRender); } protected override OnPreRender(object sender, EventArgs e) { DateTime visibleDate = (VisibleDate > new DateTime(2000, 1, 1)) ? VisibleDate : TodaysDate; myEvents = LoadEventsFromDatabase(visibleDate.Month, visibleDate.Year); } void MyCalendar_DayRender(object sender, DayRenderEventArgs e) { for(int i=0; i < myEvents.Count; i++) { if (((MyEvent)myEvents[i]).Date.Day == e.Day.Date.Day) { e.Cell.Controls.Add(new LiteralControl("
            " + ((MyEvent)myEvents[i]).EventTitle); } } } } I suppose you created MyEvent class with two properties, DateTime Date and string EventTitle. And you have a method LoadEventFromDatabase, which queries database, retrieves events and transform them into ArrayList of MyEvent objects (or you can use generic List instead of ArrayList) I hope it works :) Pilo

            M Offline
            M Offline
            munklefish
            wrote on last edited by
            #5

            Pilo, Thanks for the detailed solution. I've been away from .Net for a while now and am new to version 2.0 using VS2005. How do i go about retreiving data from the database and turning it into an array? It seemsVS2005 only allows wizard based use of the SqlDataAdapter, how do i get the data from this? Many thanks and sorry to be so demanding! :-)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups