Adding combobox to AdvancedForm.ascx

4 posts, 0 answers
  1. Michael
    Michael avatar
    21 posts
    Member since:
    Aug 2008

    Posted 31 May 2014 Link to this post

    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>

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 04 Jun 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michael
    Michael avatar
    21 posts
    Member since:
    Aug 2008

    Posted 10 Jun 2014 in reply to Boyan Dimitrov Link to this post

    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. 




  5. Michael
    Michael avatar
    21 posts
    Member since:
    Aug 2008

    Posted 12 Jun 2014 in reply to Michael Link to this post

    I fixed the issue by setting the SelectedValue this way in the AdvancedForm.ascx
    set
    {
    radDropDestination.SelectedValue = value;
    }
Back to Top