我需要在删除文章的时候同时写近日志文件 data.aspx里面
下面这段代码是 当选中一个checkbox后,删除选中项,然后写近日志页。可是写日志这段代码有问题。不知道怎么处理。请大家帮忙看一下
    protected void imgbtndel_Click(object sender, ImageClickEventArgs e)
    {
        //删除订单程序---------------------------------------------------------------------------------------------
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
        con.Open();        for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        {
            CheckBox check = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
            if (check.Checked == true)
            {
                string sqlstr = "delete from [order] where id='" + GridView1.DataKeys[i].Value + "'";
                SqlCommand cmd = new SqlCommand(sqlstr, con);
                cmd.ExecuteNonQuery();
            }
        }
        con.Close();
        bandgrid();
        Response.Write("<script>alert('删除成功!')</script>");
        //删除订单程序---------------------------------------------------------------------------------------------
        for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        {
            CheckBox check = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
           if (check.Checked == true)
           {
                string select = "select sn from [order] where id='" + GridView1.DataKeys[i].Value + "'";
                SqlCommand cmd1 = new SqlCommand(select, con);
                cmd1.ExecuteNonQuery();
                SqlDataAdapter da = new SqlDataAdapter(cmd1);
                DataSet ds = new DataSet();
                da.Fill(ds);
                string insert = "insert [history] (haction)values('" + ds.Tables[0].Rows[0].item["sn"] + "')";//就是这段话在运行时提示出错,还有,vs不能自动识别出.item。可是除了item好像没有其他的方法了。
                
                SqlCommand cmd2 = new SqlCommand(insert, con);
                
                cmd2.ExecuteNonQuery();            }
        }
        con.Close();