现在遇到这么一个问题,后台使用大文本框将挺长的一段字符串数据保存的数据库中,其中有文本中分成了几段,但是在前台从数据库中读取出来显示的时候去没有分段,查看数据库原来是没有保持分段的符号,于是采用以下办法:
保存数据时:
Code
content = content.Replace(System.Environment.NewLine, "<br/>").Replace(" ", " ");
content = content.Replace(System.Environment.NewLine, "<br/>").Replace(" ", " ");
前台读取的时候:
Code
Memo.Text = tb.Rows[0]["content"].ToString().Replace("<br/>", System.Environment.NewLine).Replace(" ", " ");
Memo.Text = tb.Rows[0]["content"].ToString().Replace("<br/>", System.Environment.NewLine).Replace(" ", " ");