1

如何通过以下方式验证 gridview 是否为空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)
  {

  }
4

1 回答 1

3

试试这个..

 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
  {
if(yourGridViewId.Rows.Count<1)
args.IsValid=false;
  }
于 2013-04-18T11:21:16.993 回答