Validation Control In DataGrid

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?
 
F

Frank Oquendo

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)
 
F

Frank Oquendo

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

Jim Heavey

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!
 

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,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top