Required Field Validator to a datagrid editt item
Tried this on another forum, but this is really a how to questions:
I want to add a Required Field Validator to a Datagrid Edit Item. I know i could do this using a template column but i forgot to add this functionality in at the start so if i could just add the functionality to the existing boundcolums dynamically or in some other way it would be great.
The onyl way i have tried so far is to try and add the control when i fire a sub from the OnItemDataBound event of the datagrid.
the sub i fire contains the following code
If (E.Item.ItemType = ListItemType.EditItem) Then
Dim rqdTitle As New RequiredFieldValidator
E.Item.Cells(3).Controls.Add(rqdTitle)
rqdTitle.ControlToValidate = (E.Item.Cells(1).Controls(0).ID)
rqdTitle.Text = "*"
End If
E.Item.Cells(1).Controls(0).ID is the textbox xontrol in the edit item on the datagrid which i want to validate.
When i click edit on an item i get the "The ControlToValidate property of '' cannot be blank. " so its obviously not seeing the control i want to validate.
As i say i would rather not go through changing all my required fields into template columns, so if there is a way to do it to a databound it would be great to know,
cheers
|