protected void DataList1_SelectedIndexChanged(object sender, EventArgs e) { ado.ketNoi(); Label lbg = (Label)DataList1.Items[DataList1.SelectedIndex].FindControl("Label10"); HyperLink hy = (HyperLink)DataList1.Items[DataList1.SelectedIndex].FindControl("HyperLink1"); lbg.Visible = true; gh = new GioHangData(); DataTable tb; if (Session["GioHang"] == null) { tb = gh.setTable(); } else { tb = (DataTable)Session["GioHang"]; } string query = "select * from tblSanPham where masp='" + hy.Text + "'"; OleDbDataAdapter da = new OleDbDataAdapter(query, ado.con); DataTable dt = new DataTable(); da.Fill(dt); foreach (DataRow dr in dt.Rows) { tb = gh.dienVaoBang(tb, dr[10].ToString(), dr["TenSP"].ToString(), 1, Convert.ToDouble(dr["Gia"]), dr["masp"].ToString()); Session["GioHang"] = tb; } }
protected void ImageButton2_Command(object sender, CommandEventArgs e) { gh = new GioHangData(); DataTable tb; if (Session["GioHang"] == null) { tb = gh.setTable(); } else { tb = (DataTable)Session["GioHang"]; } string query = "select * from tblSanPham where masp='" + lblTenSP.Text + "'"; OleDbDataAdapter da = new OleDbDataAdapter(query, ado.con); DataTable dt = new DataTable(); da.Fill(dt); foreach (DataRow dr in dt.Rows) { tb = gh.dienVaoBang(tb, dr[10].ToString(), dr["TenSP"].ToString(), 1, Convert.ToDouble(dr["Gia"]), dr["masp"].ToString()); Session["GioHang"] = tb; //Download source code tại Sharecode.vn } }