Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Cannot disable requiredfieldvalidator in datagrid

Thread Tools

Cannot disable requiredfieldvalidator in datagrid

Posts: n/a
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).
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.
The state of the requiredfieldvalidator are not saved in viewstate across
page postback in above scenario
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.
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
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable/Disable RequiredFieldValidator Alphonse Giambrone ASP .Net 2 03-27-2009 11:53 AM
Disable RequiredFieldValidator with Javascript? =?Utf-8?B?ZGhucml2ZXJzaWRl?= ASP .Net 6 06-06-2007 03:02 AM
RequiredFieldValidator disable on new page load bdtmike ASP .Net 5 02-28-2006 01:12 AM
Re: RequiredFieldValidator cannot used for IE5,cause wrong Scott M. ASP .Net 1 11-28-2003 04:46 AM
disable requiredfieldvalidator when clicking on submit button James Brett ASP .Net 4 11-26-2003 01:56 PM