usercontrol in combobox

2 posts, 0 answers
  1. ldc0618
    ldc0618 avatar
    8 posts
    Member since:
    Jun 2007

    Posted 28 Jul 2010 Link to this post

    <telerik:RadComboBox ID="ddlFolders" runat="server">
                                <telerik:RadComboBoxItem  />
                                <ItemTemplate >
                                   <uc1:PhotoMove ID="PhotoMove1" PhotoID='<%# ((GridItem)Container).ItemIndex.ToString() %>' runat="server" />

    I am trying to load a user control inside the itemtemplate of a combobox. The combox is inside a radGrid. The user control needs the PhotoID:
    '<%# ((GridItem)Container).ItemIndex.ToString() %>'

    However, this is not allowed and throws this error:
    error CS0030: Cannot convert type 'Telerik.Web.UI.RadComboBoxItem' to 'Telerik.Web.UI.GridItem' ---> System.Web.HttpParseException:

    What is an alternative way to pass a dynamic id to a nested user control that is inside a combobox which is inside a radgrid?

  2. Yana
    Yana avatar
    4963 posts

    Posted 03 Aug 2010 Link to this post


    You should subscribe to OnItemDataBound event and set this property there:

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        RadComboBox combo = (RadComboBox) e.Item.FindControl("ddlFolders");
        if(combo != null)
            ((PhotoMove)combo.Items[0].FindControl("PhotoMove1")).PhotoID = e.Item.ItemIndex.ToString();

    Please check whether the cast of the user control is correct.

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top