C# 实现

 protected void btSubmit_Click(object sender, EventArgs e)
    {
        List<CheckBox> chkList = new List<CheckBox>();
        foreach (GridViewRow row in this.GVReport.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                CheckBox chk = row.FindControl("cbActionFlag") as CheckBox;
                if (chk.Checked)
                {
                    chkList.Add(chk);
                }
            }
        }
        if (chkList.Count == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "msgChk", "alert('please select active flag!');", true);
        }
    }

Jquery 实现

<script type="text/jscript" language="javascript" src="<%=ResolveUrl("~/js/jquery-1.5.2.js") %>"></script>
<script type="text/javascript">
     var CHK_ACTION_FLAG = function(){
         $("#<%=btSubmit.ClientID%>").click(function(){
            var arrList = $("table[id$='GVReport']").find("[id$='cbActionFlag']:checked");
            if( arrList.length >0){ return true;}
            else{ return false;}
         });
     }
      $(document).ready(CHK_ACTION_FLAG);
</script>

相关文章:

  • 2021-08-14
  • 2022-01-06
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-28
  • 2021-06-24
  • 2021-12-09
  • 2021-11-21
  • 2021-12-09
  • 2021-12-09
相关资源
相似解决方案