protected void SaveButton_Clicked(object sender, EventArgs e) { if (this.TooListBox != null && this.TooListBox.Items.Count > 0) { List <Field> fields = new List <Field>(); foreach (ListItem item in this.TooListBox.Items) { Field newField = new Field(); newField.FieldName = item.Value; fields.Add(newField); } if (this.gvTemplates.SelectedIndex != -1) { CCSTemplate selectedAction = this.Templates[this.gvTemplates.SelectedIndex]; selectedAction.Title = this.TemplateTitle.Text.Trim(); selectedAction.Header = this.RichtextBox.Text.Trim(); selectedAction.Footer = this.RichtextBox2.Text.Trim(); selectedAction.Fields = fields; selectedAction.Id = selectedAction.Id; Helper.UpdateTemplate(selectedAction, SPContext.Current.List); } else { CCSTemplate newAction = new CCSTemplate(); newAction.Title = this.TemplateTitle.Text.Trim(); newAction.Header = this.RichtextBox.Text.Trim(); newAction.Footer = this.RichtextBox2.Text.Trim(); newAction.Id = Guid.NewGuid().ToString(); newAction.Fields = fields; Helper.AddTemplate(newAction, SPContext.Current.List); } btnCancel_Click(sender, e); } if (this.MessageLabel != null) { this.MessageLabel.Text = ""; } if (this.ErrorLabel != null) { this.ErrorLabel.Text = ""; } MessageLabel.Text += " Settings saved successfully."; }
protected void gvActions_SelectedIndexChanged(object sender, EventArgs e) { //this.PopulatePage(); try { CCSTemplate selectedAction = this.Templates[this.gvTemplates.SelectedIndex]; this.TemplateTitle.Text = selectedAction.Title; this.RichtextBox.Text = selectedAction.Header; this.RichtextBox2.Text = selectedAction.Footer; foreach (Field field in selectedAction.Fields) { if (field.FieldName.Equals(blankrow)) { this.TooListBox.Items.Add(field.FieldName); } else if (field.FieldName.StartsWith("- Section")) { this.TooListBox.Items.Add(field.FieldName); } else { string fldinternalName = field.FieldName; if (currentList.Fields.ContainsField(fldinternalName)) { try { string fldDisplayName = currentList.Fields.GetField(fldinternalName).Title; this.TooListBox.Items.Add(fldDisplayName); } catch { } } } } } catch { } }
protected void gvActions_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { List <CCSTemplate> ccsprint = this.Templates; if ((ccsprint != null) && (e.RowIndex < ccsprint.Count)) { CCSTemplate actionToDelete = ccsprint[e.RowIndex]; string actionIdToDelete = actionToDelete.Id; Helper.DeleteAction(actionIdToDelete, SPContext.Current.List); ccsprint.RemoveAt(e.RowIndex); this.Templates = ccsprint; //Helper.AddAction(newAction, SPContext.Current.List); this.gvTemplates.DataSource = this.Templates; this.gvTemplates.DataBind(); } } catch { } }
protected void TemplatesList_SelectedIndexChanged(object sender, EventArgs e) { string fieldName = string.Empty; string fldValues = string.Empty; string temp = string.Empty; string fld2 = string.Empty, printHead = string.Empty, printFoot = string.Empty; if (DropDownList1.SelectedValue.Equals("Item")) { this.PopulatePages(); } else { string fieldName3 = string.Empty, fld3 = string.Empty, fldValues3 = string.Empty, textVal3 = string.Empty, textVal = string.Empty; if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue)) { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName3 = expressionNode.Attributes[Constants.Field.fldFieldName].Value; fld2 = currentList.Fields.GetField(fieldName3).Title; } catch { } } textVal3 += "<td class='ms-vh'>" + fld2 + "</td>"; } } } } } foreach (SPListItem selItem in items) { textVal += "<tr>"; if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue)) { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName3 = expressionNode.Attributes[Constants.Field.fldFieldName].Value; fld3 = currentList.Fields.GetField(fieldName3).Title; fldValues3 = Convert.ToString(selItem[Convert.ToString(fld3)]); } catch { } if (!string.IsNullOrEmpty(fldValues3)) { if (fldValues3.Equals("0;#")) { fldValues3 = string.Empty; } else if (fldValues3.Contains(";#")) { fldValues3 = fldValues3.Substring(fldValues3.IndexOf(";#") + 2); } } } printHead = printHeader; printFoot = printFooter; textVal += "<td class='ms-vb2'>" + fldValues3 + "</td>"; } } } } } textVal += "</tr>"; } BdyTextBox.Text = printHead + "<br>" + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + "<tr>" + textVal3 + "</tr>" + textVal + "</table>" + "<br>" + printFoot; } }
protected void PopulatePages() { BdyTextBox.Text = string.Empty; string fieldName = string.Empty, fld2 = string.Empty; string fldValues = string.Empty, printHead = string.Empty, printFoot = string.Empty, temp = string.Empty, op2 = string.Empty; foreach (SPListItem strSelItemsID in items) { try { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value; if (fieldName.Equals(Blankrow)) { fld2 = ""; } else if (fieldName.StartsWith("- Section:")) { fld2 = fieldName; } else { fld2 = currentList.Fields.GetField(fieldName).Title; } //fldValues = currentItem.GetFormattedValue(fieldName); if (string.IsNullOrEmpty(fld2)) { fld2 = " "; fldValues = string.Empty; } else if (fld2.Contains("- Section")) { fldValues = string.Empty; } else { fldValues = Convert.ToString(strSelItemsID[fieldName]); } } catch { } } if (!string.IsNullOrEmpty(fldValues)) { if (fldValues.Equals("0;#")) { fldValues = string.Empty; } else if (fldValues.Contains(";#")) { fldValues = fldValues.Substring(fldValues.IndexOf(";#") + 2); } } if (string.IsNullOrEmpty(fld2) || fld2 == " ") { temp += "<tr>" + "<td colspan='2'>" + " " + "</td>" + "</tr>"; } else if (fld2.Contains("- Section")) { fld2 = fld2.Substring(fieldName.IndexOf("Section:") + 8); fld2 = fld2.Substring(0, fld2.IndexOf(" ")); temp += "<tr>" + "<td colspan='2' class='ms-linksectionheader'>" + "<span class='ms-standardheader'>" + fld2 + "</span>" + "</td>" + "</tr>"; } else { temp += "<tr>" + "<td class='ms-formlabel'>" + fld2 + "</td>" + "<td class='ms-formfield'>" + fldValues + "</td>" + "</tr>"; } //style=\" color:#000000; font-size:12px; font-family:Arial; border:1px solid #cccccc; background-color:#E0E0E0; font-weight:300; padding:4px\">" + fld2 + "</td>" + "<td class='ms-vb2' style=\" color:#000000; font-size:12px; font-family:Arial; border:1px solid #cccccc; padding:4px; background-color: #ffffff\" printHead = printHeader; printFoot = printFooter; } } } } } catch { } op2 = printHead + "<br>" + "<table class='iw-formtbl' border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + temp + "</table>" + "<br>" + printFoot + "<br>" + "<br>" + "<br>" + "<br>"; BdyTextBox.Text += op2; op2 = string.Empty; temp = string.Empty; } }
protected void PopulatePage() { try { string textVal = string.Empty, textVal2 = string.Empty; string val = string.Empty, printHead = string.Empty, PrintFoot = string.Empty; this.GetTemplateName(); if (items.Length == 1) { this.lbl2.Enabled = false; this.DropDownList1.Enabled = false; try { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; foreach (SPField field in currentList.Fields) { try { if (field != null && !field.Hidden)// && !field.ReadOnlyField { System.Web.UI.WebControls.ListItem newFieldItem = new System.Web.UI.WebControls.ListItem(field.Title, field.InternalName); if (!this.UnvisibleListBox.Items.Contains(newFieldItem) && this.UnvisibleListBox.Items.FindByText(field.Title) == null) { this.UnvisibleListBox.Items.Add(newFieldItem); } //AllFieldsListBox.Items.Add(field.Title); } } catch { } } for (int i = 0; i < UnvisibleListBox.Items.Count; i++) { try { val = Convert.ToString(currentItem[Convert.ToString(UnvisibleListBox.Items[i])]); if (!string.IsNullOrEmpty(val)) { if (val.Equals("0;#")) { val = string.Empty; } else if (val.Contains(";#")) { val = val.Substring(val.IndexOf(";#") + 2); } } } catch { } textVal += "<tr>" + "<td class='ms-formlabel'>" + Convert.ToString(UnvisibleListBox.Items[i]) + "</td>" + "<td class='ms-formfield'>" + val + "</td>" + "</tr>"; printHead = printHeader; PrintFoot = printFooter; } } } catch { } BdyTextBox.Text = printHead + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + textVal + "</table>" + PrintFoot; } else { string fieldName2 = string.Empty, fld2 = string.Empty, fldValues2 = string.Empty; if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue)) { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName2 = expressionNode.Attributes[Constants.Field.fldFieldName].Value; fld2 = currentList.Fields.GetField(fieldName2).Title; } catch { } } textVal2 += "<td class='ms-vh'>" + fld2 + "</td>"; } } } } } listItems = new System.Collections.Generic.List <SPListItem>(); for (int i = 0; i < items.Length; i++) { SPListItem currentListItem = currentList.GetItemById(int.Parse(items[i])); listItems.Add(currentListItem); } foreach (SPListItem selItem in listItems) { textVal += "<tr>"; if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue)) { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName2 = expressionNode.Attributes[Constants.Field.fldFieldName].Value; fld2 = currentList.Fields.GetField(fieldName2).Title; fldValues2 = Convert.ToString(selItem[Convert.ToString(fieldName2)]); } catch { } if (!string.IsNullOrEmpty(fldValues2)) { if (fldValues2.Equals("0;#")) { fldValues2 = string.Empty; } else if (fldValues2.Contains(";#")) { fldValues2 = fldValues2.Substring(fldValues2.IndexOf(";#") + 2); } } } textVal += "<td class='ms-vb2'>" + fldValues2 + "</td>"; printHead = printHeader; PrintFoot = printFooter; } } } } } textVal += "</tr>"; } BdyTextBox.Text = printHead + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + "<tr >" + textVal2 + "</tr>" + textVal + "</table>" + PrintFoot; } } catch { } }
protected void TemplatesList_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList1.SelectedValue.Equals("Item")) { this.PopulatePages(); } else { string fieldName = string.Empty; string fldValues = string.Empty; string temp = string.Empty; string fld2 = string.Empty, printHead = string.Empty, printFoot = string.Empty; if (items.Length == 1) { if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue)) { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value; if (fieldName.Equals(Blankrow)) { fld2 = ""; } else if (fieldName.StartsWith("- Section:")) { fld2 = fieldName; } else { fld2 = currentList.Fields.GetField(fieldName).Title; } //fldValues = currentItem.GetFormattedValue(fieldName); if (string.IsNullOrEmpty(fld2)) { fld2 = " "; fldValues = string.Empty; } else if (fld2.Contains("- Section")) { fldValues = string.Empty; } else { fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value; fld2 = currentList.Fields.GetField(fieldName).Title; //fldValues = currentItem.GetFormattedValue(fieldName); fldValues = Convert.ToString(currentItem[Convert.ToString(fieldName)]); } } catch { } } if (!string.IsNullOrEmpty(fldValues)) { if (fldValues.Equals("0;#")) { fldValues = string.Empty; } else if (fldValues.Contains(";#")) { fldValues = fldValues.Substring(fldValues.IndexOf(";#") + 2); } } if (string.IsNullOrEmpty(fld2) || fld2 == " ") { temp += "<tr>" + "<td colspan='2'>" + " " + "</td>" + "</tr>"; } else if (fld2.Contains("- Section")) { fld2 = fld2.Substring(fieldName.IndexOf("Section:") + 8); fld2 = fld2.Substring(0, fld2.IndexOf(" ")); temp += "<tr>" + "<td colspan='2' class='ms-linksectionheader'>" + "<span class='ms-standardheader'>" + fld2 + "</span>" + "</td>" + "</tr>"; } else { temp += "<tr>" + "<td class='ms-formlabel'>" + fld2 + "</td>" + "<td class='ms-formfield'>" + fldValues + "</td>" + "</tr>"; } //style=\" color:#000000; font-size:12px; font-family:Arial; border:1px solid #cccccc; background-color:#E0E0E0; font-weight:300; padding:4px\">" + fld2 + "</td>" + "<td class='ms-vb2' style=\" color:#000000; font-size:12px; font-family:Arial; border:1px solid #cccccc; padding:4px; background-color: #ffffff\" printHead = printHeader; printFoot = printFooter; string op2 = printHead + "<br>" + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + temp + "</table>" + "<br>" + printFoot; BdyTextBox.Text = op2; } } } } } else if (TemplatesList.SelectedItem.Text.Equals("- None -")) { //this.TemplatesList.Items.Clear(); this.PopulatePage(); } } else { string fieldName3 = string.Empty, fld3 = string.Empty, fldValues3 = string.Empty, textVal3 = string.Empty, textVal = string.Empty; if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue)) { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName3 = expressionNode.Attributes[Constants.Field.fldFieldName].Value; fld2 = currentList.Fields.GetField(fieldName3).Title; } catch { } } textVal3 += "<td class='ms-vh'>" + fld2 + "</td>"; } } } } } listItems = new System.Collections.Generic.List <SPListItem>(); for (int i = 0; i < items.Length; i++) { SPListItem currentListItem = currentList.GetItemById(int.Parse(items[i])); listItems.Add(currentListItem); } foreach (SPListItem selItem in listItems) { textVal += "<tr>"; if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue)) { XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName3 = expressionNode.Attributes[Constants.Field.fldFieldName].Value; fld3 = currentList.Fields.GetField(fieldName3).Title; fldValues3 = Convert.ToString(selItem[Convert.ToString(fld3)]); } catch { } if (!string.IsNullOrEmpty(fldValues3)) { if (fldValues3.Equals("0;#")) { fldValues3 = string.Empty; } else if (fldValues3.Contains(";#")) { fldValues3 = fldValues3.Substring(fldValues3.IndexOf(";#") + 2); } } } printHead = printHeader; printFoot = printFooter; textVal += "<td class='ms-vb2'>" + fldValues3 + "</td>"; } } } } } textVal += "</tr>"; } BdyTextBox.Text = printHead + "<br>" + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + "<tr>" + textVal3 + "</tr>" + textVal + "</table>" + "<br>" + printFoot; } } }
void TemplatesList_SelectedIndexChanged(object sender, EventArgs e) { string fieldName = string.Empty; string fldValues = string.Empty; string temp = string.Empty; string fld2 = string.Empty; string printHead = string.Empty, PrintFoot = string.Empty; if (TemplatesList.SelectedItem.Text.Equals("- None -")) { //this.TemplatesList.Items.Clear(); this.PopulatePage(); } else if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue)) { XmlDocument xmlDoc = Helper.GetConfigFile(SPContext.Current.List, Constants.ConfigFile.PrintSettingsFile); XmlNode rootNode = null; if (xmlDoc == null) { rootNode = xmlDoc.CreateElement("Templates"); xmlDoc.AppendChild(rootNode); } else { rootNode = xmlDoc.DocumentElement; } foreach (XmlNode printNode in rootNode.ChildNodes) { string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value; string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value; string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value; if (!string.IsNullOrEmpty(templateTitle)) { CCSTemplate action = new CCSTemplate(); XmlNode expressionsNode = printNode.FirstChild; if (templateTitle.Equals(TemplatesList.SelectedItem.Text)) { foreach (XmlNode expressionNode in expressionsNode.ChildNodes) { if (expressionNode.Name == Constants.Field.fldNodeName) { try { fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value; if (fieldName.Equals(Blankrow)) { fld2 = ""; } else if (fieldName.StartsWith("- Section:")) { fld2 = fieldName; } else { fld2 = SPContext.Current.List.Fields.GetField(fieldName).Title; } if (string.IsNullOrEmpty(fld2)) { fld2 = " "; fldValues = string.Empty; } else if (fld2.Contains("- Section")) { fldValues = string.Empty; } else { fldValues = Convert.ToString(currentItem[Convert.ToString(fld2)]); } } catch { } } if (!string.IsNullOrEmpty(fldValues)) { if (fldValues.Equals("0;#")) { fldValues = string.Empty; } else if (fldValues.Contains(";#")) { fldValues = fldValues.Substring(fldValues.IndexOf(";#") + 2); } } if (string.IsNullOrEmpty(fld2) || fld2 == " ") { temp += "<tr>" + "<td colspan='2'>" + " " + "</td>" + "</tr>"; } else if (fld2.Contains("- Section")) { fld2 = fld2.Substring(fieldName.IndexOf("Section:") + 8); fld2 = fld2.Substring(0, fld2.IndexOf(" ")); temp += "<tr>" + "<td colspan='2' class='ms-linksectionheader'>" + "<span class='ms-standardheader'>" + fld2 + "</span>" + "</td>" + "</tr>"; } else { temp += "<tr>" + "<td class='ms-formlabel'>" + fld2 + "</td>" + "<td class='ms-formfield' bgcolor='#F0F0F0'>" + fldValues + "</td>" + "</tr>"; } printHead = printHeader; PrintFoot = printFooter; string op2 = printHead + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + temp + "</table>" + PrintFoot; BdyTextBox.Text = op2; } } } } } }