0

我有一个DropDownList基于 Telerik的自定义控件RadComoBox。我目前正在尝试让这个自定义控件模拟另一个RadComboBox我在另一个页面上的另一个页面,该页面能够RadComboBox使用以下 aspx 在下拉列表中显示 UserFullName, (Company):

 <telerik:RadComboBox ID="rcbUsers" runat="server" Width="250px" DropDownWidth="300px" OnSelectedIndexChanged="rcbUsers_SelectedIndexChanged"
                                         HighlightTemplatedItems="true" AutoPostBack="true" Height="400px">
                        <HeaderTemplate>
                            <div>
                                Full Name (Company)
                            </div>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <div>
                                <b><%# DataBinder.Eval(Container.DataItem, "FullNameLastFirst") %></b>&nbsp;
                                (<%# DataBinder.Eval(Container.DataItem, "Company") %>)
                            </div>
                        </ItemTemplate>
                    </telerik:RadComboBox>

无论如何,我是否可以在 C# 代码中为我的自定义控件模仿这个?除了标签之外,我不需要任何 aspx 是一个要求:

<cc1:UserListBox ID="rcbUserTrained" runat="server" OnPreRender="rcbUserTrained_PreRender"/>

这可以在自定义控件的数据绑定或呈现中执行吗?

4

1 回答 1

1

I solved this awhile ago, basically I created a new class called UserListBoxColumns that inherits ITemplate. I defined my column structure there and bound the data and built it into my custom radcombobox by overrideing the CreateChildControls() method where I assigned the appropriate header/itemtemplate/footer into the comobox:

rcbUserList.HeaderTemplate = new UserListBoxColumns(ListItemType.Header);
rcbUserList.ItemTemplate = new UserListBoxColumns(ListItemType.Item);
rcbUserList.FooterTemplate = new UserListBoxColumns(ListItemType.Footer);

If you're interested email me and I can provide more details.

于 2012-09-18T20:05:57.027 回答