protected void rptSections_ItemDataBound(object sender, RepeaterItemEventArgs e) { int sectionId = int.Parse(((HiddenField)e.Item.FindControl("hfSectionId")).Value); int deptId = int.Parse(Request[WebConstants.Request.DEPT_ID]); int docId = int.Parse(Request[WebConstants.Request.DOC_ID]); DocumentTemplate.DocumentSectionEntityRow section = DatabaseUtility.GetSection(loggedInUserCoId, deptId, sectionId); if (section != null) { if (section.section_type == WebConstants.SectionTypes.FREE_TEXT) { TextBox tbItem = (TextBox)e.Item.FindControl("tbItem"); DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter itemTA = new DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter(); IEnumerator ie = itemTA.GetBySecId(loggedInUserId, deptId, docId, sectionId).GetEnumerator(); while (ie.MoveNext()) { DocumentTemplate.DocumentItemEntityRow itemRow = (DocumentTemplate.DocumentItemEntityRow)ie.Current; tbItem.Text += itemRow.item_name; } } else if (section.section_type == WebConstants.SectionTypes.MULTIPLE_SELECT_LIST) { CheckBoxList cbItem = (CheckBoxList)e.Item.FindControl("cbItem"); DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter itemTA = new DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter(); DataTable itemsDT = itemTA.GetBySecId(loggedInUserId, deptId, docId, sectionId); foreach (ListItem li in cbItem.Items) { foreach (DataRow row in itemsDT.Rows) { if (li.Value == row["section_detail_id"].ToString()) { li.Selected = true; break; } } } } } }
private void SetSectionData(DocumentType docType) { DocumentTemplateTableAdapters.DocumentSectionTableAdapter sectionTA = new DocumentTemplateTableAdapters.DocumentSectionTableAdapter(); DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter itemTA = new DocumentTemplateTableAdapters.DocumentItemEntityTableAdapter(); DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter secDetailTA = new DocumentTemplateTableAdapters.DocumentSectionDetailsTableAdapter(); IEnumerator ieSection = sectionTA.GetByDocType(docType.CoId, docType.DeptId, docType.Id).GetEnumerator(); while (ieSection.MoveNext()) { DocumentTemplate.DocumentSectionEntityRow sectionDataRow = (DocumentTemplate.DocumentSectionEntityRow)ieSection.Current; Section section = new Section(); section.Heading = sectionDataRow.section_desc; section.Type = sectionDataRow.section_type; section.SectionId = sectionDataRow.section_id; if (sectionDataRow.Isrepeat_columnsNull() == false) { section.RepeatColumns = sectionDataRow.repeat_columns; } DataTable dtItems = itemTA.GetBySecId(docType.CoId, docType.DeptId, docType.DocId, section.SectionId); if (section.Type == WebConstants.SectionTypes.MULTIPLE_SELECT_LIST) { IEnumerator ieSecDetail = secDetailTA.GetBySecId(docType.CoId, docType.DeptId, section.SectionId).GetEnumerator(); while (ieSecDetail.MoveNext()) { DocumentTemplate.DocumentSectionDetailsEntityRow secDetailDataRow = (DocumentTemplate.DocumentSectionDetailsEntityRow)ieSecDetail.Current; SectionDetail sectionDetail = new SectionDetail(secDetailDataRow.section_detail_id, secDetailDataRow.section_detail_desc, false); foreach (DataRow itemRow in dtItems.Rows) { if (secDetailDataRow.section_detail_id == (int)itemRow["section_detail_id"]) { sectionDetail.Selected = true; break; } } section.Details.Add(sectionDetail); } } if (section.Type == WebConstants.SectionTypes.FREE_TEXT) { foreach(DataRow itemRow in dtItems.Rows) { section.Text += (string)itemRow["item_name"] + "\n"; } } sectionList.Add(section); } }