ASP.NET GridView - how to enable validation declaratively -


Is it possible to enable verification in an asp.net gridview purely annotated?

What I have tried:

  • A grid view bound to an ObjectDataSource with a SelectView and UpdateMethod defined

  • Read something in GridView only the boundfield column and a TemplateField that has a text box in the template and a regular expression validator which allows numerical input in the text box only.

  • Gridview also includes a CommandField with ShowEditButton = true and the reason is validity = true.

If I click on the edit, enter an invalid value, then click Save, there is a postback, and an exception is entered in the server (input The string was not in a correct format).

I can certainly avoid this by adding a verification code to the RoW updating event handler from this server (see below), but is there a declarative way to verify without adding this code?

Protected MyGridView_RowUpdating (Object Sender, GridViewUpdateEventArgs e) {Page.Validate ("MyValidationGroup"); If (! Page.IsValid) (e.kernel = true;}}

That code is required

"In addition to relying on client-side verification, it is also important that when you handle postback events, the page is called ISIID."

update

To avoid boiler plate codes, you can get all the pages from the base class and all user controls pass through a different base class. There will be general logic in the form (as is the one above), after which you have to manually walk through the wire or the control tree and the event is automatically wired.

The form has to be with your current one.


Comments