Hello,
I have a number of template fields in a RadGrid which I wish to validate.
I've managed most validation using the Client side "RequiredFieldValidator" and server side validation using the CustomValidator.
I now want to validate one control based on the value of another control in the template.
eg
In the template field I have a Radiobuttonlist with 3 options (ie "Yes", "No", "NA"). If the user selects "No" then they have to enter text in a Textbox or the update should not proceed. If the answer is Yes they dont need to complete the Textbox.
Previously I achieved this in Gridview through something like the following. Its clunky but it works. It checks the Update data when the user tries to update. If it fails the validation they get a message and the update is cancelled.
How do I achieve the same in the Radgrid?
Cheers
Robert
I have a number of template fields in a RadGrid which I wish to validate.
I've managed most validation using the Client side "RequiredFieldValidator" and server side validation using the CustomValidator.
I now want to validate one control based on the value of another control in the template.
eg
In the template field I have a Radiobuttonlist with 3 options (ie "Yes", "No", "NA"). If the user selects "No" then they have to enter text in a Textbox or the update should not proceed. If the answer is Yes they dont need to complete the Textbox.
Previously I achieved this in Gridview through something like the following. Its clunky but it works. It checks the Update data when the user tries to update. If it fails the validation they get a message and the update is cancelled.
| Private Sub GridView2_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView2.RowUpdating |
| Dim InCompliance As String = e.NewValues("Incompliance") ' this is the value of the selected Radiobutton item |
| ' test if there are any comments |
| If e.NewValues("Comments") Is System.DBNull.Value Or e.NewValues("Comments") = "" Then 'no comments in textbox |
| If ((Trim(InCompliance) <> "Yes")) Then ' User has selected No or NA from Radiobuttonlist |
| MessageBox("You must enter a comment if you have entered a No or N/A answer") |
| e.Cancel = True 'Cancel update |
| End If |
| End If |
| End Sub |
Cheers
Robert