http://msdn.microsoft.com/en-us/library/f5db6z8k(v=vs.100).aspxから
入力されたデータが Db に存在するかどうかを確認する customeValidators.cs ページを作成しました。これは機能します。ただし、必要なページからこれを呼び出そうとすると
protected void runUniqueReference(object source, ServerValidateEventArgs args)
{
args.IsValid = (CustomValidators.UniqueReference(BOQRefTextBox.Text));
}
でエラーが発生しましたCustomValidators.UniqueReference
。「データ注釈」を「ブール」に変換できません。何か考えはありますか? 編集;
public static ValidationResult UniqueReference(string Reference)
{
ContextDB db = new ContextDB();
var lisStoredInDB =
(from Bill in db.Bill_Of_Quantities
where Bill.Reference == Reference
select Bill.Reference).ToList();
if (lisStoredInDB.Count != 0)
{
return new ValidationResult(string.Format("This reference is already stored in the database, Please enter another"));
}
return ValidationResult.Success;
}