public void Populate(string targetReference) { MainDataContext db = new MainDataContext(); if (_DataTableID != 0) { _DataTable = db._DataTables.Single(f => f.ID == _DataTableID); if (!Page.IsPostBack) { var questions = _DataTable.CRM_FormFields.Where(f => f.IsActive && !f.IsArchived).OrderBy(f => f.OrderNo); rptQuestions.DataSource = questions; rptQuestions.DataBind(); } } else { this.Visible = false; } foreach (RepeaterItem item in rptQuestions.Items) { int fieldID = Int32.Parse(((HiddenField)item.FindControl("hdnID")).Value); CRM_FormField formField = db.CRM_FormFields.SingleOrDefault(a => a.ID == fieldID); CRM.Controls.Admin.CustomFields.Form.CustomField formQuestionControl = (CRM.Controls.Admin.CustomFields.Form.CustomField)item.FindControl("ucFormQuestion"); IEnumerable <CRM_FormFieldResponse> answers = db.CRM_FormFieldResponses.Where(r => r.CRM_FormFieldID == formField.ID && r.TargetReference == targetReference); formQuestionControl.Populate(answers); } }
public List <_DataTableColumn> GetSchema() { if (GetDataTable() == null) { _DataTable datatable = new _DataTable(); datatable.TableReference = Type.Name; datatable.FriendlyName = Type.Name; datatable.IsAllowCustom = false; db._DataTables.InsertOnSubmit(datatable); db.SubmitChanges(); } int viewID = ViewID; if (viewID == -1) { AuthAdmin auth = new AuthAdmin(db); viewID = auth.Authorise().ID; } List <_DataTableColumn> dtc = (from p in GetDataTable()._DataTableColumns where p.AdminID == viewID orderby p.OrderNo select p).ToList(); if (IncludeDataReference) { var fields = GetAllFields(); _DataTableColumn tempDTC = new _DataTableColumn(); tempDTC.AdminID = 0; tempDTC._DataTableID = 0; tempDTC._DataFieldName = "Reference"; tempDTC._DataFieldFriendly = "Reference"; tempDTC.OrderNo = 999; dtc.Add(tempDTC); } return(dtc); }