Validation Control In DataGrid

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
J

Jim Heavey

Suppose I am using a series of controls in the footer of a datagrid which
allows a user to enter "a new row of information to be added to the
datagrid datasource". Some of these controls have a "RequiredValidator"
control. I am able to enter data and all is well.

On this same datagrid I have a "EditCommand" column which get the user int
the Edit/Update/Cancel mode, allowing the user to edit individual lines.
When I enter the "Edit" mode and the user enters data and presses the
"Update" link, the edits on the footer are being triggered, and it is never
reaching the "update" or "Cancel" logic.

How can I get "requiredValidator" controls in the footer to not be active
when in the edit mode?

I thought I would add the controls in code in the "Item_Created" mode and
set a flag if I was in the "Edit" mode, and if I was in the edit mode, I
would simply not add the controls to the footer. But I have been less then
successfull in adding the controls in code to the footer. I am getting a
error about the control not being well formed "Control 'txtAddMovieTitle'
of type 'TextBox' must be placed inside a form tag with runat=server.". I
have a form tag and it has a runat="Server" and my datagrid tag as well has
a "runat="Server".

Any ideas about how to get around the problem?
 
Jim said:
How can I get "requiredValidator" controls in the footer to not be
active when in the edit mode?

myValidator.Enabled = false;
// do your thing
myValidator.Enabled = true;

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Jim said:
What event should I use to change the propety back? ItemCreated?

Nope. Use the same event you used to disable the validator. Just wrap
your existing update code with those two statements and it should clear
up the problem.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
I guess I misspoke...What event would I use to set/reset the property in
the first place. I can not do it in the Edit/Update/Cancel event as it
never reaches these events because the "page is not valid". The only event
that I can see doing this in is in the item created!
 
Back
Top