Reputation: 437
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.
Upvotes: 1
Views: 1811
Reputation: 437
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
}
Upvotes: 1