文字格式问题 [英] Text format problem

查看:74
本文介绍了文字格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net的文本字段

假设我想将一些笔记保存到ms sql数据库中。

I have a text field of asp.net
Suppose I want to save some notes in to ms sql database.

1.	What is the name of your country?
2.	What is the name of your country?
3.	What is the name of your country?
4.	What is the name of your country?





我的表字段类型为文本。我可以将它存储到数据库中



但是,当我在标签中显示它时它不会保持原始格式。然后看起来像这样:



My table field type is text. I can store it into DB

However, when I show it in a label then it does not remain its original format. Then it looks like this :

1.What is the name of your country?2.What is the name of your country?3.What is the name of your country?4.What is the name of your country?





任何人都可以帮助我吗?

提前致谢



Can anyone help me?
Thanks in advance

推荐答案

将\ n新行字符(在每行的末尾)与表格中的文本一起保存。
Save the "\n" new line character (at the end of every line) along with the text in your table.


如果我理解正确,你有一个多行文本框,其值存储在数据库的单个列中?



插入行分隔符(br tag)在持久化到数据库之前或从数据库中检索值之后和渲染之前。
If I understand correctly, you have a multi-line textbox whose value is stored in a single column in your database?

Either insert the line separators (br tag) before persisting to the database or after retrieving the value from it and before rendering.


StringBuilder sb = new StringBuilder();

sb.AppendLine( 1.你的国家名称是什么?);

sb.AppendLine(2.你们国家的名字是什么?);

sb.AppendLine (3。什么是nam你们国家的电影?);

sb.AppendLine(4。您所在国家/地区的名称是什么?);

字符串数据= sb.ToString();
StringBuilder sb = new StringBuilder();
sb.AppendLine("1. What is the name of your country?");
sb.AppendLine("2. What is the name of your country?");
sb.AppendLine("3. What is the name of your country?");
sb.AppendLine("4. What is the name of your country?");
string data = sb.ToString();


这篇关于文字格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆