zoukankan      html  css  js  c++  java
  • 高分求解答!!!

     1    protected void Button1_Click(object sender, EventArgs e)
     2    {
     3        string selectedKeys = "";    //保存所有选中的记录的主键
     4        for (int i = 0; i < GVDealNow.Rows.Count; i++)
     5        {
     6            GridViewRow row = GVDealNow.Rows[i];
     7            if (row.RowType == DataControlRowType.DataRow)
     8            {
     9                //检查是否选中,假设CheckBox的ID为Checkbox1,且在GVDealNow的第一列中
    10                CheckBox cb = (CheckBox)row.Cells[9].FindControl("CBsig");
    11                //如果选中,则记录选中记录的主键
    12                if (cb.Checked)
    13                {
    14                    selectedKeys = selectedKeys + GVDealNow.DataKeys[row.RowIndex].Value.ToString() + ",";
    15                }

    16            }

    17        }

    18        if (selectedKeys != "")
    19        {
    20            selectedKeys = selectedKeys.TrimEnd(new char[] ',' });
    21            //生成sql语句,并执行删除
    22            string sql = "delete from tb_Card where CardID in (" + selectedKeys + ")";
    23            SqlConnection conn = new SqlConnection("连接字符串");
    24            SqlCommand cmd = new SqlCommand(sql);
    25            cmd.Connection = conn;
    26            cmd.CommandType = CommandType.Text;
    27            conn.Open();
    28            cmd.ExecuteNonQuery();
    29            conn.Close();
    30        }

    31        else
    32        {
    33            Response.Write("未选中要删除的记录!");
    34        }

    35
    36
    37       
    38        
    39          
    40    }
    第一列 和第十列 是模板列!

    绑定代码如下
      string sqlstr = "select * from tb_Card C  where C.CardStatus=0";
                
    this.GVDealNow.DataKeyNames = new string[] "CardID" };
                sqlBind.gvBind(GVDealNow, sqlstr);
    现在我要一次选择多尔衮删除多个 可是怎么都删不掉 一直都是未选中要删除的记录!
    请大家帮忙解决下!!

    这是数据库字段!~!
  • 相关阅读:
    php内核为变量的值分配内存的几个宏
    php7 引用成为一种类型
    function参数
    execvp php-fpm reload使用的函数
    fastcgi
    php-fpm定时器
    php 类继承
    php 对象 调用静态方法
    php unset变量
    php5数组与php7数组区别
  • 原文地址:https://www.cnblogs.com/barney/p/1159130.html
Copyright © 2011-2022 走看看