리피터 내에서 Telerik Radcombobox 사용
-
18-09-2019 - |
문제
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>
Repeater의 ItemDatabound 이벤트에서 나는 다음과 같은 항목 requested 이벤트를 배선하고 있습니다.
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 메소드는 호출되지 않습니다. ItemStatabound에서 항목 requested 이벤트를 배선하는 것이 문제가 있다고 생각하지만 문제는 다른 곳에있을 수 있습니다.
리피터 내에서 Telerik Radcombobox를 제대로 사용하는 방법에 대한 아이디어가 있습니까?
해결책
이벤트 핸들러 배선을 동적으로 추가하지 않고 마크 업에 넣었습니까?
또한 - 당신은 아마도 알고있을 것입니다. 문서를 인용하기 위해 :
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.
- 참조
시나리오가 위의 시나리오와 일치합니까?
편집하다:
코드를 테스트했습니다. 다음 작품 (항목 requested 이벤트는 모든 콤보 박스에 대해 발사되고 세 가지 테스트 항목을 즉시 드롭 다운에 추가합니다.) :
마크 업 :
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Repeater ID="rpt" runat="server" OnItemDataBound="rpt_ItemDataBound">
<ItemTemplate>
<br />
<telerik:RadComboBox ID="rcb" runat="server" EnableLoadOnDemand="true" AllowCustomText="true"
ItemRequestTimeout="1000" NumberOfItems="10" MarkFirstMatch="false" />
</ItemTemplate>
</asp:Repeater>
</form>
뒤에 코드 :
protected void Page_Load(object sender, EventArgs e)
{
List<string> data = new List<string>();
data.Add("Item 1");
data.Add("Item 2");
//add some items to the repeater to force it to bind and repeat..
rpt.DataSource = data;
rpt.DataBind();
}
protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//wire the event
RadComboBox rcb = (RadComboBox)e.Item.FindControl("rcb");
rcb.ItemsRequested += rcb_ItemsRequested;
}
protected void rcb_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
//add the items when requested.
(sender as RadComboBox).Items.Add(new RadComboBoxItem("Item1", "1"));
(sender as RadComboBox).Items.Add(new RadComboBoxItem("Item2", "2"));
(sender as RadComboBox).Items.Add(new RadComboBoxItem("Item3", "3"));
}
제휴하지 않습니다 StackOverflow