Datagrid update command - and validators

Discussion in 'ASP .Net' started by John Blair, Jan 24, 2005.

  1. John Blair

    John Blair Guest

    Hi,

    I have validators outside of a datagrid (for adding a new grid row) -
    however
    when i click "edit" column and then the "update" column of a grid row that
    has been edited - my other validators on the page fire which i don't want -
    i've tried to make them invisible - this hides the controls but i get a
    strange error when i click the Update column - i tried to disable them -
    they become disabled but i can see my error "*" appearing next to them when
    the grid "Update" command is clicked indicating validation is still being
    done- i only want grid validation to occur during update - not the entire
    page - can this be done?

    Thanks a lot!
    John Blair, Jan 24, 2005
    #1
    1. Advertising

  2. I think with 2003 even with validators assigned to diverent controls, all of
    the validators will fire. I have heard that VS 2005 is supposed to allow
    only specific validators to fire (or have a fix for this)
    other option is setting up custom validators.

    "John Blair" wrote:

    > Hi,
    >
    > I have validators outside of a datagrid (for adding a new grid row) -
    > however
    > when i click "edit" column and then the "update" column of a grid row that
    > has been edited - my other validators on the page fire which i don't want -
    > i've tried to make them invisible - this hides the controls but i get a
    > strange error when i click the Update column - i tried to disable them -
    > they become disabled but i can see my error "*" appearing next to them when
    > the grid "Update" command is clicked indicating validation is still being
    > done- i only want grid validation to occur during update - not the entire
    > page - can this be done?
    >
    > Thanks a lot!
    >
    >
    >
    =?Utf-8?B?UGF1bA==?=, Jan 25, 2005
    #2
    1. Advertising

  3. John Blair

    John Blair Guest

    Thanks for the feedback!
    In the end i filled the validators controls with valid data before disabling
    them when the grid was put into edit mode and cleared the controls when the
    grid was taken out of edit mode - not the cleanest solution but it works.
    Also toyed with the idea of dynamically adding the "causesvalidation=false"
    attribute to the grid button controls - but thought this was a hack too far!
    Just when you thought a feature was really useful the small print kicks in!
    Thanks again!

    "Paul" <> wrote in message
    news:...
    >I think with 2003 even with validators assigned to diverent controls, all
    >of
    > the validators will fire. I have heard that VS 2005 is supposed to allow
    > only specific validators to fire (or have a fix for this)
    > other option is setting up custom validators.
    >
    > "John Blair" wrote:
    >
    >> Hi,
    >>
    >> I have validators outside of a datagrid (for adding a new grid row) -
    >> however
    >> when i click "edit" column and then the "update" column of a grid row
    >> that
    >> has been edited - my other validators on the page fire which i don't
    >> want -
    >> i've tried to make them invisible - this hides the controls but i get a
    >> strange error when i click the Update column - i tried to disable them -
    >> they become disabled but i can see my error "*" appearing next to them
    >> when
    >> the grid "Update" command is clicked indicating validation is still being
    >> done- i only want grid validation to occur during update - not the entire
    >> page - can this be done?
    >>
    >> Thanks a lot!
    >>
    >>
    >>
    John Blair, Jan 25, 2005
    #3
  4. just noticed I posted the same issue today! What did you end up doing again?
    Do you have a vb.net code example? Thanx!

    chris

    "John Blair" wrote:

    > Thanks for the feedback!
    > In the end i filled the validators controls with valid data before disabling
    > them when the grid was put into edit mode and cleared the controls when the
    > grid was taken out of edit mode - not the cleanest solution but it works.
    > Also toyed with the idea of dynamically adding the "causesvalidation=false"
    > attribute to the grid button controls - but thought this was a hack too far!
    > Just when you thought a feature was really useful the small print kicks in!
    > Thanks again!
    >
    > "Paul" <> wrote in message
    > news:...
    > >I think with 2003 even with validators assigned to diverent controls, all
    > >of
    > > the validators will fire. I have heard that VS 2005 is supposed to allow
    > > only specific validators to fire (or have a fix for this)
    > > other option is setting up custom validators.
    > >
    > > "John Blair" wrote:
    > >
    > >> Hi,
    > >>
    > >> I have validators outside of a datagrid (for adding a new grid row) -
    > >> however
    > >> when i click "edit" column and then the "update" column of a grid row
    > >> that
    > >> has been edited - my other validators on the page fire which i don't
    > >> want -
    > >> i've tried to make them invisible - this hides the controls but i get a
    > >> strange error when i click the Update column - i tried to disable them -
    > >> they become disabled but i can see my error "*" appearing next to them
    > >> when
    > >> the grid "Update" command is clicked indicating validation is still being
    > >> done- i only want grid validation to occur during update - not the entire
    > >> page - can this be done?
    > >>
    > >> Thanks a lot!
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?Q2hyaXM=?=, Mar 1, 2005
    #4
  5. John Blair

    vgebrev

    Joined:
    Jan 30, 2008
    Messages:
    2
    In case anyone else is struggling with this, one solution is to set the CausesValidation property of the Update button in the OnItemCreated event handler of the DataGrid:

    if (e.Item.ItemType == ListItemType.EditItem)
    {
    LinkButton updateButton = e.Item.Cells[2].Controls[0] as LinkButton;
    if (updateButton != null)
    updateButton.CausesValidation = false;
    }

    Obviously the index of the cell would have to correspond to the index of the "Edit, Update, Cancel" ButtonColumn on your grid.
    vgebrev, Jan 30, 2008
    #5
    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. =?Utf-8?B?YWJkb2x5?=

    datagrid update command

    =?Utf-8?B?YWJkb2x5?=, Jun 1, 2004, in forum: ASP .Net
    Replies:
    10
    Views:
    6,040
    sobin
    Mar 19, 2005
  2. Ratman
    Replies:
    0
    Views:
    644
    Ratman
    Sep 14, 2004
  3. =?Utf-8?B?TWljaGFlbA==?=

    How to update datagrid after update

    =?Utf-8?B?TWljaGFlbA==?=, Mar 17, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    495
    Alex D.
    Mar 17, 2006
  4. Andreas Klemt
    Replies:
    0
    Views:
    273
    Andreas Klemt
    Oct 8, 2003
  5. prakash
    Replies:
    2
    Views:
    575
    prakash
    Apr 11, 2005
Loading...

Share This Page