I have a gridview that stores information about items - a number and a name, I have a custom validator set agains t to check the number doesn't already exist in the database to prevent duplication.
protected void CustomValTBCodeServerValidate(object source, ServerValidateEventArgs args)
{
TextBox newCode = (TextBox)fvCode.FindControl("TbCode");
String XCode = newCode.Text;
X a = (X)XManager.XGetByCode(XCode);
String existCode = a.XCode;
args.IsValid = (XCode != existCode);
if (args.IsValid == true)
{
pnlSuccess.Visible = true;
}
else
{
pnlFail.Visible = true;
}
}
However this is preventing me from updating the record as the number already exists, I need it to allow the row i'm updating to update with the code and text if the current code only exists once.
Anyone any ideas?
Thanks