开发者

Using <ItemTemplate> with Checkbox and Label

开发者_高级运维

I want to be able to show the Label next to the manually inserted item "All Profiles", right now it only shows the checkbox at the top but I am not sure how to pass the text to the label.

Thanks


Can you try something like that?

<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>


Try databinding again after inserting "All profiles"-item. If that doesnt work, try something like this:

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();


Telerik recommends to rebind added items in the DataBound event handler like the following

ddlCombobox.Items[0].DataBind()

Check the following links for similar issue on Telerik site

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜