Dynamically Add Validation to Datagrid

D

dave

I have a dgrid with some edit boxes for entry which i need to validate.

When i input the validation within the bound columns in the .aspx page it
works fine, but if try and add the validation dynamically in the code behind
file - i get the error that it cannot find the control to validate.

Is there a way round this? As i know the datagrid gives a different ID to
the control when it is bound. I need to change the validation expression on
an edit box depending on some other values.

Cheers
 
P

Pril

hello,

You have to specified .controlToValidate property. I use
validator.ControlToValidate = controlToValidate.ID

and control works just fine. Note: Id is available only after ataching
control to page object.


lp, pl
 
D

dave

Thanks for that, but still no luck...

I have the following column setup in the data grid:
<asp:templatecolumn HeaderText="QTY Required"
ItemStyle-HorizontalAlign="Right">
<itemtemplate>
<asp:textbox ID="QTY_Required" MaxLength="10" Text="0" runat="server"
Width="100" />
</itemtemplate>
</asp:templatecolumn>

And even when i just try to do response.write( qty_required.id ) within the
method that sets up the validation i get:Object reference not set to an
instance....Even although the validation method is called after the datagrid
is bound? Is there something else i am missing?

Thanks again in advance
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top