Exemplo n.º 1
0
    //删除多条记录
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        MultiProblemmr multi = new MultiProblemmr();          //创建MultiProblemmr对象

        foreach (GridViewRow dr in GridView1.Rows)            //对GridView中的每一行进行判断
        {
            if (((CheckBox)dr.FindControl("xuanze")).Checked) //如果选择了进行删除
            {
                int ID = int.Parse(((Label)dr.FindControl("Label1")).Text);
                multi.ID = ID;
                multi.DeleteByStr(ID);
            }
        }
    }
Exemplo n.º 2
0
    //删除试题事件
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        MultiProblemmr multiproblem = new MultiProblemmr();                                           //创建单选题对象
        int            ID           = int.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); //取出要删除记录的主键值

        if (multiproblem.DeleteByStr(ID))
        {
            Response.Write("<script language=javascript>alert('成功删除试题!')</script>");
        }
        else
        {
            Response.Write("<script language=javascript>alert('删除试题失败!')</script>");
        }
        GridViewBind();//重新绑定数据
    }