将<itemtemplate>与Checkbox和Label </itemtemplate>一起使用

时间:2011-07-08 18:12:56

标签: c# asp.net telerik

我希望能够在手动插入的项目“所有配置文件”旁边显示标签,现在它只显示顶部的复选框,但我不知道如何将文本传递给标签。

由于

3 个答案:

答案 0 :(得分:2)

你可以试试这样的吗?

<telerik:radcombobox id="myCombo" emptymessage="All Types" runat="server" width="200px" AppendDataBoundItems="True">       
    <ItemTemplate>         
        <div onclick="StopPropagation(event)">           
            <asp:CheckBox runat="server" ID="chk1" onclick="onCheckBoxClick(this)"/>             
            <asp:Label runat="server" ID="lblProfile" AssociatedControlID="chk1"><%# Eval("Name") %></asp:Label>               
        </div>              
    </ItemTemplate>
        <Items>                
        <telerik:RadComboBoxItem runat="server" Name="Hello"></telerik:RadComboBoxItem>
    </Items>
</telerik:radcombobox>

答案 1 :(得分:1)

插入“All profiles”-item后再次尝试数据绑定。 如果这不起作用,尝试这样的事情:

var values = myDbConnection.GetValues();
var listOfValues = values.Select(x => new ListItem(x.Name, x.Value)).ToList(); // something like that
listOfValues.Add(new ListItem("All Profiles"));

myCombo.DataSource = listOfValues;
myCombo.DataBind();

答案 2 :(得分:1)

Telerik建议重新添加 DataBound 事件处理程序中添加的项目,如下所示

ddlCombobox.Items[0].DataBind()

检查以下链接,了解Telerik网站上的类似问题

http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=327434

http://www.telerik.com/help/aspnet-ajax/combobox-insert-default-item-when-databinding.html