Listbox Selected item Link to Radscheduler AdvancedForm

8 posts, 0 answers
  1. shawn wong
    shawn wong avatar
    8 posts
    Member since:
    Apr 2010

    Posted 11 May 2010 Link to this post

     Hi Team,

    I had a RadListbox which connected to sqldatasource.

    Afterwhich, when i select the item in the Listbox, it will link me to Radscheduler Advaced Form.

    Im able to launch the Advanced form but the ID was not correct.

    Please help
    Shawn

     protected void RadListBox1_SelectedIndexChanged(object sender, EventArgs e)
         {

             foreach (RadListBoxItem currentItem in RadListBox1.Items)
             {
                 String value = currentItem.Value;
                 Appointment edittedAppointment = RadScheduler2.Appointments.FindByID(int.Parse(value));
                 RadScheduler2.ShowAdvancedEditForm(edittedAppointment);
             }
         }
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 12 May 2010 Link to this post

    Hello shawn wong,

    I suppose that the wrong DI comes from the following line:
    foreach (RadListBoxItem currentItem in RadListBox1.Items)
             {
                 String value = currentItem.Value;
                 ...
                 ...
             }

     I believe that the correct code should look like this:

    protected void RadListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
     
                String value = RadListBox1.SelectedItem.Value;
                Appointment edittedAppointment = RadScheduler2.Appointments.FindByID(int.Parse(value));
                RadScheduler2.ShowAdvancedEditForm(edittedAppointment);
             
        }



    Sincerely yours,
    Genady Sergeev
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shawn wong
    shawn wong avatar
    8 posts
    Member since:
    Apr 2010

    Posted 12 May 2010 Link to this post

    Great!,

    thanks for the help.

    Will RadListBox auto update itself?

    it was tagged to sqldatasource with Where clause.

    Thanks
    Shawn
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 17 May 2010 Link to this post

    Hello shawn wong,

    I am not sure that I understand correctly your scenario. From what I see, you have RadListBox with items. As item in selected, advanced edit form on RadScheduler is opened with the ID taken from the value of the selected RadListBox item. There is no need to update the RadListBox here. If you want to rebind your RadListBox at a later moment you can use its DataBind method.

    Regards,
    Genady Sergeev
    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.
  6. shawn wong
    shawn wong avatar
    8 posts
    Member since:
    Apr 2010

    Posted 17 May 2010 Link to this post

    Hi,

    My scenario is.

    There's no concurrent appoint for the particular user. Any "same" timing appointment will be listed as waitinglist (with DB field "waitinglist" = 1)

    Listbox contain the "Waiting List"  user

    When user double click on the waiting list, it will bring up the advanced form (solved).
    When the user move the waiting list to another time slot, it will remove it to another time slot (DB Field "waitinglist" = 0) - Solved

    So now when i save the advanced form, it will go back to MAIN scheduler with Listbox.
    However, this listbox does not refresh/rebind. It still contain the old data.

    many thanks!

    protected void RadScheduler2_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)
        {
            if (ExceedsLimitForResource(e.ModifiedAppointment, RadScheduler2.GroupBy))
            {
                foreach (Appointment a in RadScheduler2.Appointments.GetAppointmentsInRange(e.ModifiedAppointment.Start, e.ModifiedAppointment.End))
                {
                    if (a.ID != e.Appointment.ID)
                    {

                        e.ModifiedAppointment.Attributes["appt_waitinglist"] = "1";
                        SqlDataSource1.UpdateParameters["appt_waitinglist"].DefaultValue = e.ModifiedAppointment.Attributes["appt_waitinglist"];
                       
    //rebind the Listbox
    RadListBox1.DataBind();
     
                    }
                   
                }
            }
            else
            {
                e.ModifiedAppointment.Attributes["appt_waitinglist"] = null;
                SqlDataSource1.UpdateParameters["appt_waitinglist"].DefaultValue = e.ModifiedAppointment.Attributes["appt_waitinglist"];
    //rebind the Listbox
    RadListBox1.DataBind();
            }
        }

  7. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 21 May 2010 Link to this post

    Hi shawn wong,

    As far as I can see from your code you provide a parameter for the update statement but never execute the Update method of the datasource. I believe the correct version should look like this:

      .ModifiedAppointment.Attributes["appt_waitinglist"] = "1";
                        SqlDataSource1.UpdateParameters["appt_waitinglist"].DefaultValue = e.ModifiedAppointment.Attributes["appt_waitinglist"];
    SqlDataSource1.Update(); 
                      
    //rebind the Listbox
    RadListBox1.DataBind();


    If the RadListBox data source was correctly updated, the call do the databind method should have rebound the listbox with the new data.

    Regards,
    Genady Sergeev
    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.
  8. shawn wong
    shawn wong avatar
    8 posts
    Member since:
    Apr 2010

    Posted 24 May 2010 Link to this post

    Hi Genady Sergeev,

    After adding SqlDataSource1.Update();

    It does update the row. however it still does not update my ListBox. It only refresh if i hit the refresh button. Moreover, it was duplicated.

    is it possible if i could add a Panel, and refresh the panel instead?


  9. shawn wong
    shawn wong avatar
    8 posts
    Member since:
    Apr 2010

    Posted 24 May 2010 Link to this post

    I had solved.

    for those who want the solutions.
            SqlDataSource1.Update(); 
     
            RadListBox1.DataSource = null
            RadListBox1.Items.Clear(); 


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017