datagrid custom validation

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top