I have a web form that contains a Datagrid. This grid has a number of
columns, one of which contains a text box and validator for that text box.
Everything works fine, when I press the "Save" button the validator works as
expected...however...
....I want to hide certain columns under certain conditions. One of the
columns I wish to hide is the column that contains the text box and the
validator. This is done by something like
grdAddItem.Columns[5].Visible = false;
in the code behind.
Now the page renders fine, but when I press the Save button I get a
javascript error "Page_Validators is undefined". The validator is contained
within the form and the form does have runat=server set.
Am I missing something? or is this a bug?
I have found a workaround for this problem which is to add another validator
to the form together with a text box for it it to validate and make them
both invisble and set up so that the new validator always validates. If I do
this I no longer get the javascript error.
e.g.
<asp:TextBox ID=txtTest Runat=server Visible=False>1</asp:TextBox>
<asp:CompareValidator ID="Comparevalidator3" Type="Integer"
ControlToValidate="txtTest" ErrorMessage=""
Runat="server" Operator="DataTypeCheck" CssClass="errorMessage"
Display="None" ValueToCompare="1"></asp:CompareValidator>
Any ideas?
Cheers
Ian