我想在下拉菜单的顶部添加一项。我正在使用ItemTemplates,所以我正在进行数据绑定,并尝试在顶部添加一个读取的选项。
[ ] All Profiles
我已经添加了它,但它覆盖了实际数据的绑定,因此当我现在添加这个时,只有
[ ]所有个人资料
在那里,而没有真正的绑定数据。我做错了什么?顺便说一下,我是C#的新手 :)
谢谢
public void BindData()
{
myCombo.DataSource = myDbConnection.GetValues();
myCombo.DataTextField = "Name";
myCombo.DataValueField = "ID";
myCombo.DataBind();
var tempProfiles = new[] { new { Name = "All Profiles", ID = "1" } };
myCombo.DataSource = tempProfiles;
myCombo.DataBind();
}
<telerik:RadComboBox ID="myCombo" EmptyMessage="All Types" runat="server" Width="200px">
<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>
</telerik:RadComboBox>
new Telerik.Web.UI.RadComboBoxItem {
... - splattneText
和Value
。我会进行研究并在后面编辑我的回答。 - splattne