Drop down changes year in rad-scheduler.

3 posts, 0 answers
  1. John
    John avatar
    15 posts
    Member since:
    Sep 2012

    Posted 13 Sep 2012 Link to this post


    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. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Sep 2012 Link to this post

    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.
  3. John
    John avatar
    15 posts
    Member since:
    Sep 2012

    Posted 24 Sep 2012 Link to this post

    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;
    }

Back to Top