EditCommandColumn validation

  • Thread starter Thread starter RobS
  • Start date Start date
R

RobS

Can anyone answer this question:

How can I disable validation when edit column update button is pressed. Can
it be done for the whole grid?

Regards,

Robert
 
If I'm not mistaken, in the XML definition for the grid, you can set the
CausesValidation = False for the button/imagebutton.

HTH,
Morgan
 
Morgan,

Thanks for your response.

Setting CausesValidation to true works for most of asp.net controls, but
grid seems to be one of the exceptions here, unless I use hand made buttons
or image buttons. Unfortunatelly, using my own buttons for the grid edits is
my last choice, sincer it would require lots of re-coding to handle edits,
cancels and updates. I'd rather get rid of all .net validators once for all.
I am getting tired of them anyway. lol.
Or ... am I missing something?

Regards,

Robert



The problem is that in definition of EditCommandColumn for the grid, there
is no place you can put CausesValidation attribute. Or I am missing
something?
 
Hi Rob,

The EditCommandColumn includes a collection of its child controls in the
Controls property. The buttons are in there.
For example:
Button vButton = (Button) EditCommandColumn1.Controls[0];
vButton.CausesValidation = false;

You wrote: "I'd rather get rid of all .net validators once for all."
Did you know that there are replacements for Microsoft's validators? I sell
a commercial product, "Professional Validation And More", that overcomes the
limitations of Microsoft's validators and greatly expands what you can do.
Some of its features are 17 validators, group validation, client-side
support on many browsers, new ways to get the user's attention and format
the error message, and a client-side toolkit to make more interactive web
forms. Details are at http://www.peterblum.com/vam/home.aspx.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
 
My earlier answer is incorrect. The EditCommandColumn class is not
subclassed from WebControl. So it doesn't have a Controls collection.

Here's a correction. Set up the ItemCreated event on DataGrid. Inside it,
you have access to the current row in e.Items. It is actually the TableRow
class, with its Cells containing the controls. Identify the column number
containing the EditCommandColumn. Then do this (shown in C#):

TableCell vCell = e.Item.Cells[column number]; // column numbers start at
0
if (vCell.Controls.Count > 0)
((Button)vCell.Controls[0]).CausesValidation = false;

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)

Peter Blum said:
Hi Rob,

The EditCommandColumn includes a collection of its child controls in the
Controls property. The buttons are in there.
For example:
Button vButton = (Button) EditCommandColumn1.Controls[0];
vButton.CausesValidation = false;

You wrote: "I'd rather get rid of all .net validators once for all."
Did you know that there are replacements for Microsoft's validators? I sell
a commercial product, "Professional Validation And More", that overcomes the
limitations of Microsoft's validators and greatly expands what you can do.
Some of its features are 17 validators, group validation, client-side
support on many browsers, new ways to get the user's attention and format
the error message, and a client-side toolkit to make more interactive web
forms. Details are at http://www.peterblum.com/vam/home.aspx.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)

RobS said:
Morgan,

Thanks for your response.

Setting CausesValidation to true works for most of asp.net controls, but
grid seems to be one of the exceptions here, unless I use hand made buttons
or image buttons. Unfortunatelly, using my own buttons for the grid
edits
is
my last choice, sincer it would require lots of re-coding to handle edits,
cancels and updates. I'd rather get rid of all .net validators once for all.
I am getting tired of them anyway. lol.
Or ... am I missing something?

Regards,

Robert



The problem is that in definition of EditCommandColumn for the grid, there
is no place you can put CausesValidation attribute. Or I am missing
something?
 
Back
Top