我有一个RadGrid,其中的一列是一个GridTemplateColumn,它有一个RadComboBox加载一些项目(编辑模式设置为'PopUp')。 我想要的是,如果在RadComboBox中搜索一个项目时,找不到任何项目,那么给用户一个添加新项目的选项。目前,仅用于测试目的,如果没有找到项目,我希望能够显示一条消息。这是我迄今为止所尝试的。如果在搜索后没有找到任何项目,RadComboBox显示消息
我的radgrid控件内radcombobox控件定义如下:
<EditItemTemplate>
<telerik:RadComboBox runat="server" ID="Product_PKRadComboBox"
ShowDropDownOnTextboxClick="false" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
EnableLoadOnDemand="true" EnableAutomaticLoadOnDemand="true" ItemsPerRequest="10"
OnItemsRequested="Product_PKRadComboBox_ItemsRequested" AllowCustomText="true"
Filter="StartsWith" DataSourceID="SqlProducts" DataTextField="ProductCode"
DataValueField="Product_PK"></telerik:RadComboBox>
</EditItemTemplate>
所以我在我的“OnItemsRequested”事件的逻辑如下:
protected void Product_PKRadComboBox_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
//RadComboBox combo = (RadComboBox)sender;
if (e.EndOfItems && e.NumberOfItems==0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "testMessage", "alert('Product Not Found. Do you want to add a Custom Product?');", true);
//Page.ClientScript.RegisterStartupScript(typeof(Page), "some_name", "if(confirm('here the message')==false)return false;");
}
}
我试过内的代码都行IF语句(它检查用户在RadComboBox中输入的内容是否存在,如果它不返回任何项目,则显示一条消息),但它们都不起作用。我在调试模式下尝试了相同的操作,并在IF语句中的行上设置了一个断点,但它实际上执行了但我看不到警报。