写进去的时候:
string mycon = ConfigurationSettings.AppSettings["mc"];
        SqlConnection con = new SqlConnection(mycon);
        con.Open();
        string content1 = TextArea1.Value;
        string content3 = Server.HtmlEncode(content1);
        string str1 = "update art set content=@content";
        
       
        SqlCommand com = new SqlCommand(str1, con);
        com.Parameters.Add(new SqlParameter("@content",SqlDbType.Text));
        com.Parameters["@content"].Value = content3;
        com.ExecuteNonQuery();
读出来的时候:
string str2 = "select content from art where id=1";        SqlDataReader dr = SqlHelper.ExecuteReader(con,CommandType.Text,str2);
        while (dr.Read())
        {
            string cont = Server.HtmlDecode(dr[0].ToString());
            Label2.Text = cont;
这种只能正常显示空格,不能正确换行,是不是label不能换行显示的,如果我要把正确换行显示该怎么做,谢谢

解决方案 »

  1.   

    replace("\r\n","<br/>");或者用
    <pre>...</pre>
      

  2.   

    将字符串里的换行符替换成 <br /> 像这样:
    Label2.Text = cont.Replace("\r\n", "<br />");
      

  3.   

    你的label要不要自动换行啊 
    style="word-break:break-all" 
      

  4.   

    显示的时候,把   \n   \r   替换成   "<br   />"   
      

  5.   

    把" " 替换成 &nbsp;
      

  6.   

    顶楼上的!!!在HTML里一看什么都明白了!!!兄弟有空看看吧!!!