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

usercontrol in combobox

1 Answer 35 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
ldc0618
Top achievements
Rank 1
ldc0618 asked on 28 Jul 2010, 10:10 PM
<telerik:RadComboBox ID="ddlFolders" runat="server">
                            <Items>
                            <telerik:RadComboBoxItem  />
                            </Items>
                            <ItemTemplate >
                               <uc1:PhotoMove ID="PhotoMove1" PhotoID='<%# ((GridItem)Container).ItemIndex.ToString() %>' runat="server" />
                            </ItemTemplate>
                            </telerik:RadComboBox>

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?

Thanks!

1 Answer, 1 is accepted

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

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,
Yana
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
Tags
ComboBox
Asked by
ldc0618
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or