Cannot disable requiredfieldvalidator in datagrid

F

Fluxray

--Background:
I have a webform including a datagrid. The datagrid is using template. Its
ItemTemplate is used to display a look-up-table with labels. its
EditItemTemplate is used to edit a row in the look-up-table with textboxes. I
have a linkbutton in each row (causevalidation = false) named 'Edit' to post
the page back such that the page is switch from display mode to edit mode
(labels -> textboxes for the row to be edited), and the textboxes, are
associated with a group of validators (call them Edit-Validators). At the
same time, I have one row of textboxes in the FooterTemplate, which is for
the user to add one record to the look-up-table. And this footer template is
displayed in both modes through the postback. A set of requiredfield
validator are set for this row (call them Add-Validators).
--Objective:
When clicking the 'Edit' linkbutton in anyrow, I want the Add-validators to
be disabled. So I set all the "visible" properties to be false for all
Add-validators in the itemcommand event, which is triggered by the 'Edit'
linkbutton. But when the page is rendered in the client after the postback
(Now the 'Edit' LinkButton is replaced by a 'Save' LinkButton with
causevalidation=true), and when i click the Save LinkButton, the validators
in Add-Validators are still checked in client-side script.
--Summary
The state of the requiredfieldvalidator are not saved in viewstate across
page postback in above scenario
--Debug:
From debug information, in the first postback the visible property of
requiredfieldvalidators are set to false successfully. But in the second
postback, it is true again. Means the state information is not kept in
viewstate but it should be.
--Testing case:
I have tried this with a simple project, with similar scenario without
datagrid(only 2 textboxes eaching having a requiredfieldvalidators
associated, and two buttons, A to trigger the postback to disable one
validator, B to test the validation). It works fine. The validators are
disabled when setting the visible to false in server side code triggered by
the first button A.
--Question
Why the requiredfieldvalidator can be disabled in my simple testing, but
does not work in the datagrid?
--Thanks in advance, folks
let me know if you want to know more
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top