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

Adding combobox to AdvancedForm.ascx

3 Answers 129 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 31 May 2014, 07:35 PM
I have added a ComboBox control to the AdvancedForm.ascx.  When the advanced form is displayed, the selected item in the combobox is not shown.  Stepping through the code, I can see radDropDestination.SelectedIndex = dest.Index; properly being set.  How do you set the SelectedIndex for the ComboBox or properly bind the Combobox so the selected item is shown when the AdvancedForm.ascx is displayed?  


<telerik:RadComboBox ID="radDropDeparture" runat="server" Width="350px" EmptyMessage="-- Depart from ---" DataSourceID="DataSourceDeparture" DataTextField="DepartureName" DataValueField="Id" Skin="Glow" MaxHeight="300px" EnableAutomaticLoadOnDemand="false" EnableItemCaching="true"></telerik:RadComboBox>


Code behind for AdvancedForm.ascx

[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
      public string DestinationID
      {
          get
          {
              return radDropDestination.SelectedValue;
          }
 
          set
          {
                if (value == null)
                  return;
                radDropDestination.DataBind();
              RadComboBoxItem dest = radDropDestination.FindItemByValue(value);
              radDropDestination.SelectedIndex = dest.Index;
          }
      }

From the default.aspx

<AdvancedEditTemplate>
                  <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit" Subject='<%# Bind("Subject") %>'
                      Description='<%# Bind("Description") %>' Start='<%# Bind("Start") %>' End='<%# Bind("End") %>'
                      RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' Reminder='<%# Bind("Reminder") %>'
                      DestinationID='<%# Bind("DestinationID") %>' DepartureID='<%# Bind("DepartureID") %>' />
              </AdvancedEditTemplate>

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 04 Jun 2014, 03:34 PM
Hello,

We are not aware of such problem with the RadComboBox control. Please try setting the selected item in the RadComboBox ItemDataBound by simply:
//code behind
e.Item.Selected = true;



Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Michael
Top achievements
Rank 1
answered on 11 Jun 2014, 03:11 AM
I have added the following code.

protected void radDropDestination_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
   {
             e.Item.Selected = true;
   }

This gets called once per item in the comobox and leaves the last item selected instead of the bound item.  When editing an appointment, if I change the selected item and save the appointment, the database is updated.  If I step through the code, the proper item is bound (value contains the correct value) but after the form is rendered, nothing is selected. 




0
Michael
Top achievements
Rank 1
answered on 13 Jun 2014, 02:50 AM
I fixed the issue by setting the SelectedValue this way in the AdvancedForm.ascx
set
{
radDropDestination.SelectedValue = value;
}
Tags
Scheduler
Asked by
Michael
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Michael
Top achievements
Rank 1
Share this question
or