protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "capnhat": gh = new GioHangData(); DataTable dt = (DataTable)Session["GioHang"]; foreach (GridViewRow gr in GridView1.Rows) { TextBox txtsl = (TextBox)gr.FindControl("txtsoluong"); if (Convert.ToInt32(txtsl.Text) > 0) { dt = gh.capNhatlai(dt, double.Parse(txtsl.Text), gr.Cells[1].Text); } else { dt = gh.xoaDong(dt, gr.Cells[1].Text); if (dt.Rows.Count == 0) { Panel2.Visible = true; Panel3.Visible = false; } } } GridView1.DataSource = dt; GridView1.DataBind(); tinhtien(dt); Session["GioHang"] = dt; break; } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { gh = new GioHangData(); DataTable tb = (DataTable)Session["GioHang"]; tb = gh.xoaDong(tb, GridView1.Rows[e.RowIndex].Cells[1].Text); GridView1.DataSource = tb; GridView1.DataBind(); Session["GioHang"] = tb; if (Session["GioHang"] != null) { DataTable dt = (DataTable)Session["GioHang"]; if (dt.Rows.Count == 0) { Panel2.Visible = true; Panel3.Visible = false; } } }