Datagrid update command - and validators

J

John Blair

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!
 
G

Guest

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.
 
J

John Blair

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!
 
G

Guest

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
 
Joined
Jan 30, 2008
Messages
2
Reaction score
0
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.
 

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

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top