Guides/How-do-I-add-a-line-break-inside-of-a-block-of-text-in-my-database.md
... ...
@@ -0,0 +1,64 @@
1
+#How do I add a line break inside of a block of text in my database?
2
+
3
+[[_TOC_]]
4
+
5
+##Question
6
+
7
+I have long blocks of text in my database, and line breaks aren't being respected. How can I add these?
8
+
9
+##Answer
10
+
11
+By default, this text will not appear in the Database the way it was typed in the field. This text will also not appear in the Report Writer the way it was typed in the field. You can force line breaks using special characters. This can be done by overriding the ProcessDataSet method, or by using a custom formatter. A custom format is less dangerous, easier to implement by a user, and is reusable across reports. Please see the following code example:
12
+
13
+###Code Sample
14
+
15
+```csharp
16
+[Serializable]
17
+ public class HtmlTextFormatter : IFormatter
18
+ {
19
+ public Type GetOutputDataType(DataTable table, int columnNumber, ReportOutputOptions reportOutputOptions, Field field)
20
+ {
21
+ return typeof(string);
22
+ }
23
+
24
+ public object Format(DataTable table, int rowNumber, int columnNumber, Field field, DataTable originalTable, Field nameField)
25
+ {
26
+ object value = table.Rows[rowNumber][columnNumber];
27
+ if (value == null)
28
+ return "";
29
+ return value.ToString().Replace("\r\n", "<br/>");
30
+ }
31
+ }
32
+
33
+ [Serializable]
34
+ public class HtmlTextFormat : IFormat
35
+ {
36
+ public SqlTypeGroupCollection AllowedTypeGroups
37
+ {
38
+ get { return null; }
39
+ }
40
+
41
+ public SqlTypeGroupCollection DisallowedTypeGroups
42
+ {
43
+ get { return null; }
44
+ }
45
+
46
+ public string Name { get { return "HTML Text"; } }
47
+
48
+ public SqlTypeGroup DefaultFor
49
+ {
50
+ get { return SqlTypeGroup.None; }
51
+ }
52
+
53
+ public bool Visible
54
+ {
55
+ get { return true; }
56
+ }
57
+
58
+ public IFormatter[] CreateFormatters()
59
+ {
60
+ return new IFormatter[] { new HtmlTextFormatter() };
61
+ }
62
+ }
63
+
64
+```
... ...
\ No newline at end of file