Home All Groups Group Topic Archive Search About

Dynamically Add Validation to Datagrid

Author
23 Mar 2005 7:09 AM
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

[attached file: printer.gif]

Author
23 Mar 2005 9:48 AM
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

Show quoteHide quote
"dave" <d***@edin.co.uk> wrote in message
news:%23euI1a3LFHA.4092@tk2msftngp13.phx.gbl...
> 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
>
>
>
Author
23 Mar 2005 10:42 AM
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




Show quoteHide quote
"Pril" <pril@NOSPAMemail.si> wrote in message
news:uJfs864LFHA.904@tk2msftngp13.phx.gbl...
> 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
>
> "dave" <d***@edin.co.uk> wrote in message
> news:%23euI1a3LFHA.4092@tk2msftngp13.phx.gbl...
>> 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
>>
>>
>>
>
>