zoukankan      html  css  js  c++  java
  • c# 全选和批量修改

    //全选
    function checkAll(){
    var items = document.getElementsByTagName("input");
    for(var i =0;i<items.length;i++){
    if(items[i].type == "checkbox" && items[i].id.indexOf("CheckBox1")>0){
    items[i].checked = document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl01_CheckBox3").checked;
    }
    }
    }
    
    function checkAlls(){
    var items = document.getElementsByTagName("input");
    for(var i =0;i<items.length;i++){
    if(items[i].type == "checkbox" && items[i].id.indexOf("CheckBox2")>0){
    items[i].checked = document.getElementById("ctl00_ContentPlaceHolder1_GridView2_ctl01_CheckBox4").checked;
    }
    }
    }
    //批量修改删除
    string ids = "";
    //遍历所有数据行
    for (int i = 0; i < GridView1.Rows.Count; i++)
    {
    CheckBox chk = GridView1.Rows[i].FindControl("CheckBox1") as CheckBox;
    if (chk.Checked)
    {
    //通过主键获取
    ids +="'"+ GridView1.DataKeys[i].Value.ToString()+"'" + ",";
    }
    }
    if (ids.Length == 0)
    {
    Response.Write("<script>alert('您没有选择!!!')</script>");
    return;
    }
    else
    {
    //去掉最后逗号
    ids = ids.Substring(0,ids.Length-1);
    //访问数据库
    SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=GameCardSale;Integrated Security=True");
    string sql = "Update UserInfo set UserRole=3 where UserId in ("+ids+")";
    SqlCommand comm = new SqlCommand(sql,conn);
    conn.Open();
    int num = comm.ExecuteNonQuery();
    conn.Close();
    if (num > 0)
    {
    Response.Write("<script>alert('会员通过审核成功!!!')</script>");
    }
    else
    {
    Response.Write("<script>alert('网络繁忙!!请稍后再试!!!')</script>");
    }
    GridView1.DataBind();
    
    
    }
  • 相关阅读:
    (7)常量和变量
    (6)python基础数据类型
    PEP8规范
    (5)原码反码补码
    (4)二八十六进制转换
    (3)你的第一个python程序
    (2)python开发环境搭建
    几种常见的开发语言对比
    (1)python的基础认知
    (25)线程---local数据隔离
  • 原文地址:https://www.cnblogs.com/panjuan/p/3829071.html
Copyright © 2011-2022 走看看