Question

How to validate the gridview for emptiness through the custom validator :


 <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="!!! "
                                        ControlToValidate="GridView1" ValidationGroup="Add_valid" OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>

  protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
  {

  }
Était-ce utile?

La solution

try this..

 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
  {
if(yourGridViewId.Rows.Count<1)
args.IsValid=false;
  }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top