show events when click on the date

2 posts, 0 answers
  1. Y L
    Y L avatar
    16 posts
    Member since:
    May 2010

    Posted 19 May 2010 Link to this post

    Hello,

    I'm working on a page that has a RadCanlendar control. What I want to do is when the user clicks on the date, if it has events on that day, the RadGrid that contains the detailed information of the events will display.   Now I don't know how to pass the value of the selected date to the grid.

    Can anyone give me some idea? Many thanks !

  2. Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 25 May 2010 Link to this post

    Hi Y L,

    You could try the following approach:

    On RadCalendar.SelectionChanged event handler you could get the selected date form the calendar and add the date into the Session variable. Then you could call RadGrid.Rebind() method:
    void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
    {
         SelectedDate = e.SelectedDates[0].Date;
         RadGrid1.Rebind();
    }

    The Rebind() method will force the RadGrid to fire its NeedDataSource event. Into the RadGrid.NeedDataSource event handler you could get from the database the events which is related for the selected date from the Session variable:
    public DateTime SelectedDate
    {
         get
         {
             return (DateTime)Session["EventDatetime"];
         }
         set
         {
             Session["EventDatetime"] = value;
         }
    }
        
    void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        if (SelectedDate != null)
        {
            DataTable table = // get events by SelectedData
            RadGrid1.DataSource = table;
        }
    }

    Additionally I am sending you a simple example which demonstrates the desired functionality.

    I hope this helps.

    All the best,
    Radoslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top