网页上改,数据库中改一样把'\n'换成"<br>"

解决方案 »

  1.   

    sql语句  select ...,myA5,... from ...
    改为 select ...,Replace(myA5,'\n','<br>'),... from ...
      

  2.   

    比如
    sql语句
    select ...,Replace(myA5,'\n','<br>') as myA5,...
      

  3.   

    不行啊,系统老是提示:
    "System.Data.OleDb.OleDbException: 表达式中 'Replace' 函数未定义"
    的错误,望指教
      

  4.   

    惨!不行 "System.Data.OleDb.OleDbException:  表达式中  'Replace'  函数未定义"
      

  5.   

    哦,sqlserver是可以的,其他数据库难说
    这样吧
    把TextBox1.Text存进数据库时处理,
    TextBox1.Text.Replace("\n","<br>").Replace(" ","&nbsp&nbsp")
    替换掉换行与空格
      

  6.   

    更简单的方法:
     DataBinder.Eval(Container.DataItem,  "myA5") =>DataBinder.Eval(Container.DataItem,  "myA5").Replace("\n","<br>")
      

  7.   

    哪个不行呀?嗯,最后那个应该是
    DataBinder.Eval(Container.DataItem,"myA5","{0}").Replace("\n","<br>").Replace(" ","&nbsp&nbsp")
      

  8.   

    在vb中Replace函数能够使用,但在C#中好象有问题,但在SDK的帮助文件中确实有Replace函数:
    [Visual Basic]
    Overloads Public Shared Function Replace( _
       ByVal input As String, _
       ByVal pattern As String, _
       ByVal replacement As String _
    ) As String
    ----------------------------[C#]
    public static string Replace(
       string input,
       string pattern,
       string replacement
    );我试过一个例子:
    vb中:
         sub Button1_click(Sender as object,e as EventArgs)
               label1.Tex=Replace(TextArea.Text,"\n", "<BR>");
         end sub
     能通过
    c#中:
         public void Button_click(object sender,EventArgs e)
        {
         Label1.Text =Replace(TextArea.Text, "\n", "<BR>");
        }
       出现:
    " The name 'Replace' does not exist in the class or namespace " 的错误
      

  9.   

    更正:
    将TextArea.Text全改为TextArea.Value
      

  10.   

    c#中string对象本身就有Replace这个方法
    所以应该为Label1.Text=Label1.Text.Replace("","")
      

  11.   

    <  td  ><pre>  <  %#  DataBinder.Eval(Container.DataItem,  "myA5")%>  </pre><  /td>