GridView空行验证 [英] GridView Empty Row Validation

查看:84
本文介绍了GridView空行验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要验证gridview(即是否为空)
(Gridview数据将由用户通过数据表填充.)

在我的代码中找不到Gridview1.
并建议我的代码/方法正确..
//================================================ =======

I need to validate a gridview (ie. is empty or not)
(Gridview data will be filled by user through datatable.)

In my code it is not able to find the Gridview1.
and also advise my code / way is correct..
//=======================================================

<script  language="javascript" type ="text/javascript" >
     function gvPostDatedChequeValidation(source, args)
       {
        var Grid = document.getElementById("<%=GridView1.ClientID%>");
        if (Grid.Rows.Count>0 )
         {
         args.IsValid = true;
         }
         else
         {
         args.IsValid = false;
         }
       }
       </script>


//================================================ ============


//=============================================================

<asp:GridView ID="GridView1" runat="server">
  </asp:GridView>

  <asp:CustomValidator ID="CustomValidator2" runat="server"  ErrorMessage="Fill Blank Cheque Details"

  ClientValidationFunction="gvPostDatedChequeValidation">*</asp:CustomValidator>

  <asp:Button ID="Button1" runat="server" Text="Button" />

推荐答案

Count属性在javascript中无效
使用这样的length属性

Count property is not valid in javascript
use length property like this

if (Grid.rows.length>0 )
        {
}


这篇关于GridView空行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆