How to fix the asp.net DetailsView data validation problem - Digital Tool Factory blog How to fix the asp.net DetailsView data validation problem - Digital Tool Factory blog

How to fix the asp.net DetailsView data validation problem

Jugando con texturas (XIII): Resurrecciónphoto © 2010 Zyllan | more info ia: Wylio) The Problem: You have the standard asp.net DetailsView control (one of many on that page) and your custom validator refuses to work.  So do all of your standard validators now that you think about it.  Your command button looks like this:

<asp:ButtonField ButtonType="Button" ValidationGroup="Main" Text="Add This" CommandName="InsertNewRecord"  />
and all of your ValidationGroups are set to "Main"

The Cause: DetailsView is designed to work that  way, don’t ask me why

The Solution: Put everything in a regular button, like so:

<asp:TemplateField><InsertItemTemplate>
<asp:Button runat="server" ID="btnAddNewAddress" ValidationGroup="Main" CommandName="InsertNewRecord"  Text="Add This"/>
</InsertItemTemplate>
</asp:TemplateField>
That works, no idea why, but it does.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog

 

Written By Steve French

 

2 responses to “How to fix the asp.net DetailsView data validation problem”

Leave a Reply

Your email address will not be published. Required fields are marked *






Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.