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

About the author

Steve French Steve is the President and lead developer of Digital Tool Factory and currently provides all technical development for DTF. Digital Tool Factory has provided behind the scenes technical muscle to the Atlanta design community since 2002.Google+ Profile

 

Written By Steve French

 

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

  1. Your totally correct with this writing!!!

Leave a Reply





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