关于数据实现批量删除

所谓批量删除或更新就是一下实现对多条数据的操作,不要我们一条一条的去操作(如果当数据达到上百条或千条,老大你一条条的修改或删除,那你不是传说中的...可呵,开下玩笑了)

其实批量删除或者修改也不就那么回事情,下面是基本代码(实现批理操作有许多种方法,大家可根椐自已的系统需求找自需要的方法)!

 protected void Button1_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < griew.Rows.Count; i++)
        {
            TextBox txtPClassName = (TextBox)(griew.Rows[i].FindControl("txtProutName")); //取得模板中控件的对象
            int id = Convert.ToInt32(griew.DataKeys[i].Value); //取得主键
            string sql = "update Product set  ProductName ='" + txtPClassName.Text + "',ProductSize=510  where ProductID=" + id; //执行sql语句
            clsMySql.ExecuteNonQuery(sql);执行语句操作
        }
        Bind();
    }

 

 

相关文章:

  • 2021-06-23
  • 2021-09-04
  • 2021-06-14
  • 2022-12-23
  • 2021-07-20
  • 2021-09-23
  • 2022-01-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
  • 2022-03-08
相关资源
相似解决方案