如何通过自定义验证器验证gridview的空白?

时间:2013-04-18 11:12:53

标签: c# asp.net gridview user-controls customvalidator

如何通过custom validator

验证gridview的空白
 <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)
  {

  }

1 个答案:

答案 0 :(得分:3)

试试这个..

 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
  {
if(yourGridViewId.Rows.Count<1)
args.IsValid=false;
  }