• 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();
    
    
    }
  • 相关阅读:
    UISearchBar clearButton
    github上不了改下host
    github命令
    quick-lua调试
    UIButton Making the hit area larger
    linux中crontab实现以秒执行任务
    学习linux必备服务器VPS
    JAVA线程全局异常处理
    spring基础
    <s:select>自动加标签
  • 原文地址:https://www.cnblogs.com/panjuan/p/3829071.html
Copyright © 2020-2023  润新知