RadComboBox with FooterTemplate

1 posts, 0 answers
  1. Neepa
    Neepa avatar
    25 posts
    Member since:
    Jun 2012

    Posted 08 Mar 2017 Link to this post

    I've a radcomboBox with footertemplate that allows me to add new items to the radcombobox.  My RCB has onClientSelectedIndexChanged event that would fire when the selected index is changed.  When I use footerTemplate to add new item - it does not fire this event.  Can you please help.

     

    <telerik:RadComboBox ID="rcbClass" runat="server" Width="400px" DropDownAutoWidth="Enabled" AllowCustomText="false" MarkFirstMatch="true" AutoPostBack="true"                                            OnClientSelectedIndexChanged="ChangeEffortClassification"
          <FooterTemplate>
               <asp:TextBox ID="tbClassDetail" runat="server" ClientIDMode="Static"></asp:TextBox>                                   
               <asp:Button ID="btnAddClass" runat="server" Text="Add Classification" OnClick="btnClass_Click" ClientIDMode="Static" CausesValidation="false" OnClientClick="return validateGroupAndSetWaiting(this,'vgRCBFooter');" />
              <asp:RequiredFieldValidator ID="rfvClassDetail" runat="server" ControlToValidate="tbClassDetail"
                 ErrorMessage="New Class cannot be blank" ValidationGroup="vgRCBFooter"></asp:RequiredFieldValidator>
        </FooterTemplate>                                  
    </telerik:RadComboBox>
     
    protected void btnClass_Click(object sender, EventArgs e)
            {
                Page.Validate("vgRCBFooter");
                if (!Page.IsValid) return;
     
                Button btnAddClass = sender as Button;
                TextBox txtClassDetail = (TextBox)btnAddClass.NamingContainer.FindControl("tbClassDetail");
                Telerik.Web.UI.RadComboBox rcbClassDetail = (Telerik.Web.UI.RadComboBox)btnAddClass.NamingContainer.Parent;           
     
                if (!String.IsNullOrEmpty(txtClassDetail.Text))
                {
                    rcbClassDetail.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem(txtClassDetail.Text));
                    rcbClassDetail.SelectedIndex = 0;
                    txtClassDetail.Text = String.Empty;
                }
            }
Back to Top