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

usercontrol in combobox

1 Answer 35 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
ldc0618 asked on 28 Jul 2010, 10:10 PM
<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?


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 03 Aug 2010, 03:24 PM

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
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question