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

combobox with custom items

1 Answer 102 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
sf
Top achievements
Rank 1
sf asked on 10 Nov 2010, 08:17 AM
is it possible to add 2 linkbutton controls inside a radcombobox? the demo only uses databound template items...
thanks in advance

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Nov 2010, 11:39 AM
Hello,
I am not quite sure about your requirement.
If you want to add the link button for all the items, then you could make use of ItemTemplate and add from mark-up itself.

ASPX:
<telerik:RadComboBox DataSourceID="SqlDataSource1" HighlightTemplatedItems="true"
            DataTextField="LastName" DataValueField="LastName" ID="RadComboBox1" runat="server"
            AllowCustomText="true" OnItemCreated="RadComboBox1_ItemCreated">
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" Text="lButton1"></asp:LinkButton>
                <asp:LinkButton ID="LinkButton2" runat="server" Text="lButton2"></asp:LinkButton>
            </ItemTemplate>
</telerik:RadComboBox>

In the case of you need LinkButtons as first two items, then you can do it in the RadComboBox1_ItemCreated event like below.

C#:
protected void RadComboBox1_ItemCreated(object sender, Telerik.Web.UI.RadComboBoxItemEventArgs e)
  {
      if (e.Item.Index < 2)
      {
          LinkButton lnkButton = new LinkButton();
          lnkButton.Text = "New LinkButton";
          e.Item.Controls.Add(lnkButton);
      }
  }

Feel free to share the comments.

Thanks,
Princy.
Tags
ComboBox
Asked by
sf
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or