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

Listbox Selected item Link to Radscheduler AdvancedForm

7 Answers 121 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
shawn wong
Top achievements
Rank 1
shawn wong asked on 12 May 2010, 02:57 AM
 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);
         }
     }

7 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 12 May 2010, 08:19 AM
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.
0
shawn wong
Top achievements
Rank 1
answered on 12 May 2010, 01:11 PM
Great!,

thanks for the help.

Will RadListBox auto update itself?

it was tagged to sqldatasource with Where clause.

Thanks
Shawn
0
Genady Sergeev
Telerik team
answered on 17 May 2010, 10:00 AM
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.
0
shawn wong
Top achievements
Rank 1
answered on 17 May 2010, 07:43 PM
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();
        }
    }

0
Genady Sergeev
Telerik team
answered on 21 May 2010, 09:02 AM
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.
0
shawn wong
Top achievements
Rank 1
answered on 24 May 2010, 07:51 AM
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?


0
shawn wong
Top achievements
Rank 1
answered on 24 May 2010, 11:49 AM
I had solved.

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


Tags
ListBox
Asked by
shawn wong
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
shawn wong
Top achievements
Rank 1
Share this question
or