在中继器中使用 Telerik RadComboBox
我有一个包含 Telerik RadComboBox 的转发器:
<asp:Repeater ID="rpt" runat="server">
<ItemTemplate>
<telerik:RadComboBox ID="rcb" runat="server" EnableLoadOnDemand="true"
AllowCustomText="true" ItemRequestTimeout="1000"
NumberOfItems="10" MarkFirstMatch="false">
</telerik:RadComboBox>
</ItemTemplate>
</asp:Repeater>
在转发器的 ItemDataBound 事件中,我像这样连接 ItemsRequested 事件:
private void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e) {
RadComboBox rcb = (RadComboBox)e.Item.FindControl("rcb");
rcb.ItemsRequested += rcb_ItemsRequested;
}
private void rcb_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) {
// Database call to load items occurs here.
// As configured, this method is never called.
}
目前,从未调用服务器端 rcb_ItemsRequested 方法。我怀疑在 ItemDataBound 中连接 ItemsRequested 事件有问题,但问题可能出在其他地方。
关于如何在中继器中正确使用 Telerik RadComboBox 有什么想法吗?
I have a repeater that contains a Telerik RadComboBox:
<asp:Repeater ID="rpt" runat="server">
<ItemTemplate>
<telerik:RadComboBox ID="rcb" runat="server" EnableLoadOnDemand="true"
AllowCustomText="true" ItemRequestTimeout="1000"
NumberOfItems="10" MarkFirstMatch="false">
</telerik:RadComboBox>
</ItemTemplate>
</asp:Repeater>
In the ItemDataBound event of the Repeater, I am wiring up the ItemsRequested event like this:
private void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e) {
RadComboBox rcb = (RadComboBox)e.Item.FindControl("rcb");
rcb.ItemsRequested += rcb_ItemsRequested;
}
private void rcb_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) {
// Database call to load items occurs here.
// As configured, this method is never called.
}
Currently, the server-side rcb_ItemsRequested method is never called. I suspect that wiring the ItemsRequested event in the ItemDataBound is problematic, but the problem may lie elsewhere.
Any ideas on how to use the Telerik RadComboBox within a repeater properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过将事件处理程序接线放入标记中而不是动态添加它?
另外 - 您可能知道,但以防万一 - ItemsRequested 是一个仅在某些条件下触发的事件。引用文档:
当 EnabledLoadOnDemand 属性为 True 并且用户在输入字段中键入文本或在列表为空时单击下拉切换图像时,会发生 ItemsRequested 事件。
- 参考您的情况与上述情况相符吗?
编辑:
我测试了一些代码。以下工作(为所有组合框触发 ItemsRequested 事件并将三个测试项目动态添加到下拉列表中..):
标记:
隐藏代码:
Have you tried putting the event handler wiring in the markup rather than adding it dynamically?
Also - you are probably aware, but just in case - ItemsRequested is an event that only fires under certain conditions. To quote the docs:
The ItemsRequested event occurs when the EnabledLoadOnDemand property is True and the user types text into the input field or clicks on the drop-down toggle image when the list is empty.
- ReferenceDoes your scenario match the above?
EDIT:
I've tested some code. The following works (The ItemsRequested Event fires for the all ComboBoxes and adds the three test items to the dropdown on the fly..):
Markup:
code behind: