public string GetLayoutXML() { using (StringWriter sw = new StringWriter()) { XmlWriterSettings settings = new XmlWriterSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.OmitXmlDeclaration = true; using (XmlWriter xw = XmlWriter.Create(sw, settings)) { xw.WriteStartElement("OrderManagementGrid" + filter.ToString()); xw.WriteAttributeString("ActiveFilterString", gridView1.ActiveFilterString); xw.WriteAttributeString("ActiveFilterEnabled", "" + gridView1.ActiveFilterEnabled); foreach (GridColumn col in gridView1.Columns) { xw.WriteStartElement(col.Caption); xw.WriteAttributeString("Visible", "" + col.Visible); xw.WriteAttributeString("VisibleIndex", "" + col.VisibleIndex); xw.WriteAttributeString("Width", "" + col.Width); xw.WriteAttributeString("SortOrder", "" + col.SortOrder.ToString()); xw.WriteAttributeString("SortIndex", "" + col.SortIndex); xw.WriteEndElement(); } xw.WriteEndElement(); } return(sw.ToString()); } }