Background
I have a GridView where input in Column1 depends on the input Column2.
- If a user enters a
NinColumn2the system will put aYinColumn1.
The Validatons are implemented using Regexs and Custom validation. I would prefer a validation solution that doesn’t use JavaScript.
|Column1| Column2| __________________ | Y | N __________________ |N | Y __________________ |N | N
Question
How can I validate these entries in the Gridview without using JavaScript?
You could use radio buttons and the ‘Template’ column feature of a GridView. The GridView markup would look like this:
The trick then would be to correctly set the ‘GroupName’ property of each radio button so that each row of the resulting grid is treated as a single radio button group by the browser. That’s where the ‘OnRowDataBound’ handler specified on the grid comes into play. The definition of the ‘gvTest_RowDataBound’ handler method could be something like:
By appending the row index to the group name to both of the radio buttons in each row you’re going to ensure that the browser will treat them as a group and only allow the selection of one value per row. The result would look something like this: