日期:2014-05-17 浏览次数:20441 次
<asp:CustomValidator ID="CustomValidator_ContractNumber" runat="server"
ErrorMessage="合同号已存在" Font-Size="10px"
onservervalidate="CustomValidator_ContractNumber_ServerValidate"></asp:CustomValidator>
protected void CustomValidator_ContractNumber_ServerValidate(object source, ServerValidateEventArgs args)
{
DataClassesDataContext db = new DataClassesDataContext();
ContractTable mypt;
args.IsValid = false;
try//多个参数同时判定的写法!!!
{
mypt = db.ContractTable.Where(c => c.ContractNumber == ((TextBox)this.FormView1.FindControl("ContractNumberTextBox")).Text).First();
}
catch
{
args.IsValid = true;
}
}