1

How do I open DropDown of RadComboBox on asp:Button click? Both RadComboBox and Button are inside EditItemTemplate of RadGrid.

My requirement is: I had to open DropDown of RadComboBox ("ddlAccountCode" in below HTML code) on a click of button ("btnSearch" in below HTML code).

Below is the HTML code of RadComboBox and Button

    <telerik:GridTemplateColumn UniqueName="AccountCode" HeaderText="Account Code">
        <ItemTemplate>
             <asp:Label ID="lblAcCode" runat="server" Text='<%# Eval("AccountCode")%>'></asp:Label>
        </ItemTemplate>
        <EditItemTemplate>
             <asp:Label ID="lblAcCode2" runat="server" Text='<%# Eval("AccountCode") + " - " + Eval("AccountDescription")%>' Visible="false"></asp:Label>
             <telerik:RadComboBox ID="ddlAccountCode" runat="server" Height="200" Width="240" DropDownWidth="310" HighlightTemplatedItems="true" CausesValidation="true" 
OnItemsRequested="ddlAccountCode_ItemsRequested" EnableItemCaching="true" ShowDropDownOnTextboxClick="false" EnableLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true" MarkFirstMatch="True" AllowCustomText="true"
Filter="Contains" AppendDataBoundItems="true" DataTextField="AccountDescription" DataValueField="AccountCodeID" AutoPostBack="true" OnSelectedIndexChanged="ddlAccountCode_SelectedIndexChanged">
             </telerik:RadComboBox>                            
             <telerik:RadButton id="btnSearch" runat="server" text="Search" OnClick="btnSearch_Click">
             </telerik:RadButton>
          </EditItemTemplate>
    </telerik:GridTemplateColumn>

I am doing searching/filtering in RadComboBox on a button click. All is working fine except when I type/search anything in textbox of RadComboBox and click on button to search, the dropdown of RadCombo does not open up. Due to this, every time, I have to manually open the dropdown to see the result of searched text in RadComboBox.

Joshua Dwire
  • 5,415
  • 5
  • 29
  • 50
timz_123
  • 435
  • 1
  • 9
  • 47
  • I am stuck in it since 3 days. I am in urgent need of the solution regarding the same. Please reply to my posted question. – timz_123 Sep 04 '15 at 02:14
  • Feel free to [start a bounty](http://stackoverflow.com/help/bounty) to draw attention to your question. – Michael Liu Sep 04 '15 at 02:54

1 Answers1

1

Below line of code is working fine for my requirement:

protected void btnSearch_Click(object sender, EventArgs e)
    {
        GridEditableItem editedItem = (sender as Button).NamingContainer as GridEditableItem;
        RadComboBox combo = (RadComboBox)editedItem.FindControl("ddlAccountCode");
        combo.OpenDropDownOnLoad = true; // opens dropdown of RadComboBox
    }
timz_123
  • 435
  • 1
  • 9
  • 47