コード例 #1
0
    //添加
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Button1.Text == "添加分类")
        {
            Button1.Text = "更新";
            M_Cate temp = new M_Cate();
            if (TextBox1.Text == "")
            {
                return;
            }
            temp.CateName = TextBox1.Text;
            if (B_Cate.Add(temp))
            {
                string str = " <script>alert('Add success'); </script>";
                Response.Write(str);
            }
            Bind();
        }
        if (Button1.Text == "更新")
        {
            Button1.Text = "添加分类";
            M_Cate temp = new M_Cate();
            temp.CateName = TextBox1.Text;

            B_Cate.Update(temp);
            Bind();
        }
    }
コード例 #2
0
    //全选



    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "mydelete")
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                CheckBox IdCheck;
                IdCheck = (CheckBox)GridView1.Rows[i].FindControl("nameCheckBox");
                if (IdCheck.Checked)
                {
                    B_Cate.DeleteByID(Convert.ToInt32(e.CommandArgument.ToString()));
                    Bind();
                }
            }
        }
        if (e.CommandName == "myupdate")
        {
            Session.Add("cateid", e.CommandArgument);
            M_Cate tempcate = new M_Cate();
            tempcate      = B_Cate.GetCateByid(Convert.ToInt32(e.CommandArgument.ToString()));
            TextBox1.Text = tempcate.CateName;
            Button1.Text  = "更新";
        }
        if (e.CommandName == "mylink")
        {
            Response.Redirect("datamanage.aspx?cateid=" + e.CommandArgument);
            Response.End();
        }
    }
コード例 #3
0
    private void Bind()
    {
        DataView dv = B_Cate.GetCateInfo();

        this.GridView1.DataSource = dv;
        GridView1.DataKeyNames    = new string[] { "CateID" };
        this.GridView1.DataBind();
    }
コード例 #4
0
ファイル: DataManage.aspx.cs プロジェクト: zwt-zf/cms
    protected void Page_Load(object sender, EventArgs e)
    {
        M_Cate temp   = new M_Cate();
        int    CateID = Convert.ToInt32(Request.QueryString["cateid"]);

        Session.Add("CateId", CateID);
        temp             = B_Cate.GetCateByid(CateID);
        this.Label2.Text = temp.CateName;
        if (!Page.IsPostBack)
        {
            Bind();
        }
    }
コード例 #5
0
 //批量删除
 protected void Button2_Click(object sender, EventArgs e)
 {
     for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
     {
         CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("nameCheckBox");
         if (cbox.Checked == true)
         {
             int CateID = Convert.ToInt32(GridView1.DataKeys[i].Value);
             B_Cate.DeleteByID(CateID);
         }
     }
     Bind();
 }