private void rptLoaiThiNghiemBind() { rptLoaiThiNghiem.DataSource = DAO.clsLoaiThiNghiemDAO.getListLoaiThiNghiem(); rptLoaiThiNghiem.DataBind(); DAO.clsCotThiNghiem_Mapping CTN = new DAO.clsCotThiNghiem_Mapping(); DataTable TableCTN = CTN.getFullCotThiNghiem(); foreach (RepeaterItem item in rptLoaiThiNghiem.Items) { Repeater CotTN = item.FindControl("rptCotThiNghiem") as Repeater; Label ID = item.FindControl("lblID_LoaiThiNghiem") as Label; Button btnThemCot = item.FindControl("btn_ThemCot") as Button; DataView t = new DataView(TableCTN); btnThemCot.Visible = true; t.RowFilter = "ID_LoaiThiNghiem=" + ID.Text; if (t.Count == 4) { btnThemCot.Visible = false; } CotTN.DataSource = t; CotTN.DataBind(); if (t.Count > 0) { Button btnXoa = CotTN.Items[t.Count - 1].FindControl("btn_XoaCot") as Button; btnXoa.Visible = true; } } }
protected void btn_ThemLoaiThiNghiem_Click(object sender, EventArgs e) { DAO.clsCotThiNghiem_Mapping CTNDAO = new DAO.clsCotThiNghiem_Mapping(); int lastID = DAO.clsLoaiThiNghiemDAO.insertThiNghiemNewLastID(); if (CTNDAO.insertNew(lastID)) { Response.Redirect(Request.RawUrl); } }