HtmlEncode/HtmlDecode问题

weiflyes 2006-11-18 05:58:35
我在TextBox(TextMode:MultiLine)中写数据,然后用HtmlEncode()保存在数据库,然后用HtmlDecode读出来,读出来在TextBox(TextMode:MultiLine)中能够正确显示,但是TextMode:MultiLine的TextBox有个滚动条很不好看,于是我用Label或直接输出,试了却不能正确显示(该换行的地方不换行了。。。。。)?

另一个问题是我都用TextBox(TextMode:MultiLine)来写和显示数据可以正确换行和显示文字,但我保存代码如下的代码就不行了(下边的这些代码插不进数据库,也没有任何错误信息),

下面是我想存入数据库的文本:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
int money = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "MONEY"));
if (money == 77)
e.Row.BackColor = Color.Red;
string customer = DataBinder.Eval(e.Row.DataItem, "CUSTOMER").ToString();
if (customer == "sdf")
e.Row.BackColor = Color.Red;
}
if (e.Row.RowType == DataControlRowType.DataRow {

e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow',this.style.fontWeight='';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
  e.Row.Attributes.Add("onclick","this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';");
}
...全文
104 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2006-11-18
  • 打赏
  • 举报
回复
不用HtmlEncode
Label.Text = str.Replace("\r\n","<br/>");

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧