我在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';");
}
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';");
}
Label.Text = str.Replace("\r\n","<br/>");