M
Mike P
Is it possible to use custom validators when editing a datagrid? I'm
asking this because I am trying to use a custom validator to validate a
control which is in an <edititemtemplate> tag and when I try to
reference it in my C# the control is not
recognised .
My code is :
<asp:customvalidator ID="valCustom" runat="server" ForeColor="#FFFFFF"
ControlToValidate="txtDCUG" OnServerValidate="Validate_DCUG"
Display="Static" ErrorMessage="Invalid DCUG"></asp:customvalidator>
public void Validate_DCUG(object sender,
System.Web.UI.WebControls.ServerValidateEventArgs value)
{
bool blnValid = true;
int intDCUG = Convert.ToInt32(txtDCUG.Text);
if (intDCUG > 4000)
{
}
else
{
valCustom.ErrorMessage = "The DCUG you have entered does not exist";
blnValid = false;
}
value.IsValid = blnValid;
return;
}
I know that the code in Validate_DCUG can be done instead by a
validator, I am just using this procedure to test that I can use custom
validation at the moment.
Any assistance would be much appreciated.
Cheers,
Mike
asking this because I am trying to use a custom validator to validate a
control which is in an <edititemtemplate> tag and when I try to
reference it in my C# the control is not
recognised .
My code is :
<asp:customvalidator ID="valCustom" runat="server" ForeColor="#FFFFFF"
ControlToValidate="txtDCUG" OnServerValidate="Validate_DCUG"
Display="Static" ErrorMessage="Invalid DCUG"></asp:customvalidator>
public void Validate_DCUG(object sender,
System.Web.UI.WebControls.ServerValidateEventArgs value)
{
bool blnValid = true;
int intDCUG = Convert.ToInt32(txtDCUG.Text);
if (intDCUG > 4000)
{
}
else
{
valCustom.ErrorMessage = "The DCUG you have entered does not exist";
blnValid = false;
}
value.IsValid = blnValid;
return;
}
I know that the code in Validate_DCUG can be done instead by a
validator, I am just using this procedure to test that I can use custom
validation at the moment.
Any assistance would be much appreciated.
Cheers,
Mike