|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dynamically Add Validation to DatagridI 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] 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 > > > 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 >> >> >> > >
UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
Compact code Add text from listbox into datagrid column iterate through only one column of a datagrid Access individual item in a datagrid Add row to datagrid? Can't get text value of hidden (visible = false) column.. Datagrid sorting does not work Help DataGrid doesn't do HTML entity encoding. |
|||||||||||||||||||||||