This is a migrated thread and some comments may be shown as answers.

show events when click on the date

1 Answer 31 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Y L
Top achievements
Rank 1
Y L asked on 19 May 2010, 05:54 PM
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 !

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 25 May 2010, 01:30 PM
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.
Tags
Calendar
Asked by
Y L
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or