Cannot disable requiredfieldvalidator in datagrid

Discussion in 'ASP .Net Web Controls' started by Fluxray, Sep 17, 2004.

  1. Fluxray

    Fluxray Guest

    --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
    Fluxray, Sep 17, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Brett
    Replies:
    4
    Views:
    11,704
    James Brett
    Nov 26, 2003
  2. Scott M.
    Replies:
    1
    Views:
    327
    ʹÃûÑï
    Nov 28, 2003
  3. Alphonse Giambrone

    Enable/Disable RequiredFieldValidator

    Alphonse Giambrone, Dec 19, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    6,416
    addicted.adi
    Mar 27, 2009
  4. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    Disable RequiredFieldValidator with Javascript?

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Sep 15, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    35,352
    ananth_goud1
    Jun 6, 2007
  5. bdtmike
    Replies:
    5
    Views:
    4,772
    bdtmike
    Feb 28, 2006
Loading...

Share This Page