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

Drop down changes year in rad-scheduler.

2 Answers 62 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 13 Sep 2012, 01:04 PM

Hi 

I have an asp drop down list with a list of years 12/13 11/12 10/11,

I want to know how if a user picks 11/12 it changes the year of the radscheduler to the year 2011. 

so far on page load it just gives you the current day,month and year.


cheers

John M


2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Sep 2012, 05:04 AM
Hi John,

I suppose you want to rebind the RadScheduler based on the selected text in the DropDownList. Following is the sample code that I tried based on your scenario.

ASPX:
<telerik:RadScheduler ID="RadScheduler1" runat="server" ......... >
</telerik:RadScheduler>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" onselectedindexchanged="DropDownList1_SelectedIndexChanged" >
  <asp:ListItem Text="12/13"></asp:ListItem>
  <asp:ListItem Text="11/12"></asp:ListItem>
  <asp:ListItem Text="10/11"></asp:ListItem>
</asp:DropDownList>

C#:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedItem.Text == "12/13")
        {
            DateTime value = new DateTime(2012, DateTime.Today.Month, DateTime.Today.Day);
            RadScheduler1.SelectedDate=value;
            RadScheduler1.Rebind();
        }
        else if (DropDownList1.SelectedItem.Text == "11/12")
        {
            DateTime value = new DateTime(2011, DateTime.Today.Month, DateTime.Today.Day);
            RadScheduler1.SelectedDate = value;
            RadScheduler1.Rebind();
        }
        else if (DropDownList1.SelectedItem.Text == "10/11")
        {
            DateTime value = new DateTime(2010, DateTime.Today.Month, DateTime.Today.Day);
            RadScheduler1.SelectedDate = value;
            RadScheduler1.Rebind();
        }
    }

Hope this helps.

Regards,
Princy.
0
John
Top achievements
Rank 1
answered on 24 Sep 2012, 12:52 PM
Hi Princy

The code you gave me, got me started cheers.

Because I have the dates linked to a database so when a new term starts it automatic adds to the dropdown so I couldn't use the if statements linked to a certain date.

Here is my code which I used instead.

private void DropDownDisplayYearChange ()
{
DateTime value = new DateTime(2000 + Convert.ToInt32(AcademicYearDropDown.SelectedValue.ToString().Substring(0, 2)), DateTime.Today.Month, DateTime.Today.Day);
RadScheduler1.SelectedDate = value;
}

Tags
Scheduler
Asked by
John
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or