zoukankan      html  css  js  c++  java
  • ASP.NET 判断GRIDVIEW的checkbox是否选中

    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>

  • 相关阅读:
    迅为RK3399开发板嵌入式linux开发指南
    迅为iMX8M Mini开发板NXP i.MX8系列ARM cortex A53 M4核心板
    谱聚类(上篇)
    html 新增标签
    前段文件上传
    vue设置cookie和获取cookie
    vue 中使用element ui 回显问题
    vue实现表格自建与表格内容填写
    Delphi Datasnap Post请求
    Nginx SSL 配置https
  • 原文地址:https://www.cnblogs.com/zhangchenliang/p/2077730.html
Copyright © 2011-2022 走看看