Esempio n. 1
0
 private void Bind()
 {
     this.GridView1.DataSource = B_CateDetail.GetcatedetailAll(Convert.ToInt32(Session["CateId"]));
     GridView1.DataKeyNames    = new string[] { "CateDetailID" };
     this.GridView1.DataBind();
     if (GridView1.Rows.Count == 0)
     {
         Label3.Text            = "没有此分类下的数据值";
         this.CheckBox1.Visible = false;
         this.Button7.Visible   = false;
     }
 }
Esempio n. 2
0
 //批量删除
 protected void Button7_Click(object sender, EventArgs e)
 {
     for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
     {
         CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("detailCheckBox");
         if (cbox.Checked == true)
         {
             int catedetailID = Convert.ToInt32(GridView1.DataKeys[i].Value);
             B_CateDetail.DeleteByID(catedetailID);
         }
     }
     Bind();
 }
Esempio n. 3
0
 protected void Button8_Click(object sender, EventArgs e)
 {
     if (Button8.Text == "添加")
     {
         M_CateDetail temp = new M_CateDetail();
         temp.CateDetailName = TextBox1.Text;
         temp.CateID         = Convert.ToInt32(Session["cateid"]);
         if (B_CateDetail.Add(temp))
         {
             this.Bind();
         }
     }
     if (Button8.Text == "更新")
     {
         Button8.Text = "添加";
         M_CateDetail temp = new M_CateDetail();
         temp.CateID         = Convert.ToInt32(Session["CateID"]);
         temp.CateDetailName = TextBox1.Text;
         temp.CateDetailID   = Convert.ToInt32(Session["catedetailid"]);
         B_CateDetail.Update(temp);
         this.Bind();
     }
 }
Esempio n. 4
0
    protected void GridView1_RowCommand1(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("detailCheckBox");
                if (IdCheck.Checked)
                {
                    B_CateDetail.DeleteByID(Convert.ToInt32(e.CommandArgument.ToString()));
                }
            }
        }
        if (e.CommandName == "myupdate")
        {
            Session.Add("catedetailid", e.CommandArgument);
            M_CateDetail temp = B_CateDetail.GetcatedetailById(Convert.ToInt32(e.CommandArgument));

            TextBox1.Text = temp.CateDetailName;
            Button8.Text  = "更新";
        }
    }