私の列の 1 つが GridTemplateColumn である RadGrid があり、いくつかの項目をロードする RadComboBox があります (編集モードは「PopUp」に設定されています)。私が欲しいのは、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 ステートメント内の行にブレークポイントを設定しました。実際には実行されますが、アラートが表示されません。