If you're like me, you've implemented Dynamic Data with master-detail pages that include GridView controls and perhaps multiple drill-down DetailsView controls or other form controls.

You also proceeded to realize that validating two or more controls on the same page with DynamicFields is hard, to the say the least. Luckily, I found a streamlined solution!

Before I point out the solution, I have to say, "Thanks!" to the great folks at Microsoft for actually bothering to help me with my lowly requests.

Earlier I asked Scott Guthrie about my problems with URL rewriting and now one of members of the Dynamic Data team, Scott Hunter, actually said because many users are requesting it that the team is implementing validation groups for DynamicFields in the next release. Whoo!

Until the next version, Scott pointed out this asp.net thread for the solution (at the end).

Here it is, simple and easy:

namespace JJ.Controls
{
   public class ValidationGroupDynamicField: DynamicField
    {

        private string _validationGroup;
        public string ValidationGroup
        {
            get
            {
                return _validationGroup;
            }
            set
            {
                _validationGroup = value;
            }
        }

        public override void InitializeCell(
        System.Web.UI.WebControls.DataControlFieldCell cell, 
        System.Web.UI.WebControls.DataControlCellType cellType, 
        System.Web.UI.WebControls.DataControlRowState rowState, 
        int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);

            if (cellType == DataControlCellType.DataCell)
            {
                if (ValidationGroup != null)
                    ((DynamicControl)cell.Controls[0]).ValidationGroup
                         = ValidationGroup;
            }
        }
    }
}

Then, register the namespace in your ASPX file:

<%@ Register Assembly="CustomControls" Namespace="JJ.Controls" TagPrefix="jj" %>

Then, in your ASPX file:

<Fields>
    <jj:ValidationGroupDynamicField DataField="Url" 
           ValidationGroup="myGroup" />
</Fields>

Thank you to Scott Hunter and javan15 for the solution!