我有一個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語句中的行上設置了一個斷點,但它實際上執行了但我看不到警報。