title: ObjectDataSource, CustomValidators and DataBinding
body: <p>I have an ObjectDataSource that is bound to a GridView. The object accepts a parameter from a TextBox. The problem I have is when I use a CustomerValidator with a ServerValidate event, the  ObjectDataSource would still attempt to perform a DataBind despite the fact the the customer validator has returned false.</p>
  
  <p>The following is the code in the ASPX page.</p>
  
  <pre><code>&lt;asp:TextBox ID="sittingDate" runat="server" /&gt;
  &lt;asp:CustomValidator ID="DateValidator" runat="server" ControlToValidate="sittingDate" OnServerValidate="DateValidator_ServerValidate" /&gt;
  &lt;asp:ObjectDataSource ID="BatchDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
          SelectMethod="GetOrCreateSittingBatch" TypeName="BatchBLL" OnSelected="BatchDataSource_Selected" OnSelecting="BatchDataSource_Selecting"&gt;
          &lt;SelectParameters&gt;
              &lt;asp:ControlParameter ControlID="sittingDate" Name="batchDate" PropertyName="Text"
                  Type="DateTime" /&gt;
          &lt;/SelectParameters&gt;
      &lt;/asp:ObjectDataSource&gt;
  &lt;asp:GridView ID="BatchGridView" runat="server" DataSourceID="BatchDataSource"&gt;
  </code></pre>
  
  <p>In the Custom Validator I have</p>
  
  <pre><code>protected void DateValidator_ServerValidate(object source, ServerValidateEventArgs args)
  {
          //Ensure that the entered data is a date.
          string input = args.Value;
  
          DateTime result;
          args.IsValid = DateTime.TryParse(input.TrimEnd(), out result);
  }
  </code></pre>
  
  <p>How do I stop the ObjectDataSource from data binding when validation has failed?</p>