protected void HospitalFormView_PreRender(object sender, EventArgs e) { if (Roles.IsUserInRole("Users")) { HospitalFormView.FindControl("EditBtn").Visible = false; HospitalFormView.FindControl("DeleteBtn").Visible = false; } }
protected void FormView1_ItemDeleting(object sender, FormViewDeleteEventArgs e) { Label lbl = HospitalFormView.FindControl("ViewId") as Label; var hospitalId = long.Parse(lbl.Text); var elements = from element in _dataContext.Visits where element.hospitalId == hospitalId select element; if (elements.Count() != 0) { _dataContext.Visits.DeleteAllOnSubmit(elements); _dataContext.SubmitChanges(); return; } }