Hi,
In the table t_contents of database MySql version 8.0.17 I have stored in field/column contents the text that contains HTML code
On the GridView in markup page aspx using ASP.NET C#
I have set for correctly output
<asp:TemplateField HeaderText="Test"
ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lbtest" runat="server"
Text='<%# HttpUtility.HtmlDecode(Eval("contents").ToString()) %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtext"
runat="server"
TextMode="MultiLine"
Text='<%# HttpUtility.HtmlDecode(Eval("contents").ToString()) %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
Now I need insert new line (break) on this html text each 20 letters using
Text='<%# HttpUtility.HtmlDecode(SpliceText(Eval("contents").ToString(),20))%>'
public static string SpliceText(string text, int lineLength)
{
var charCount = 0;
var lines = text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)
.GroupBy(w => (charCount += w.Length + 1) / lineLength)
.Select(g => string.Join(" ", g));
return String.Join("<br />", lines.ToArray());
}
The problem it's inserting the SpliceText the output in gridview contains html code open.
With the SpliceText function
Without the SpliceText function
How to to resolve this?
Can you help me? Thanks