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

RadComboBox with FooterTemplate

0 Answers 148 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Neepa
Top achievements
Rank 1
Neepa asked on 08 Mar 2017, 09:18 PM

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;
            }
        }

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Neepa
Top achievements
Rank 1
Share this question
or