how to connect a validator programmatically to a bound datagrid

M

Mark Kamoski

Everyone--

I have a DataGrid that is bound at run-time.

Upon the click of the Add, a new row is added to the top and it has several
types of controls, (but, it is not permissible to use the built-in editing
functionality of the DataGrid).

The DataGrid is bound.

Now, the user fills out the controls and clicks Save at which point I need
to validate.

However, the ReqFieldValidator controls cannot be bound to the controls
they should because sometimes the grid is empty to begin with.

Therefore, I have a placeholder which is loaded programmatically with a
ValidationSummary control and several validation controls.

The problem is that the page is choking on trying to set the
controlToValidate property. Somehow, it cannot find the control it has to
bind, even though it is in the Declarations section and on the ASPX page.

I think this is because it is part of an itemTemplate, but I don't know for
sure.

So, how can this be done programmatically?

(The run-time engine will not allow it if I try to add the
ReqFieldValidators to the ASPX page and set their ControlToValidate
property to a control in an ItemTemplate-- it cannot find the control.)

Any ideas are welcome.

Thank you.

--Mark
 

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,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top