按照书上写的设置的,可就是出错了,帮忙看看编译错误 
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0103: 当前上下文中不存在名称“Replace”源错误: 行 60:                             <asp:TemplateField HeaderText="内容" SortExpression="news_content">
行 61:                                 <ItemTemplate>
行 62:                                     <asp:Label ID="Label1" runat="server" Text='<%# Replace(Eval("news_content"),vbcrlf,"<br>") %>'></asp:Label>
行 63:                                     <asp:Label ID="Label2" runat="server" Height="32px" Text='<%# Replace(Eval("news_content"),vbcrlf,"<br>") %>'
行 64:                                         Width="118px"></asp:Label>
 源文件: d:\vs2005\news\newsDetail.aspx    行: 62 显示详细的编译器输出:
D:\Program Files\Microsoft Visual Studio 8\Common7\IDE> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.dll" /D:DEBUG /debug+ /optimize- /win32res:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\boxe1olx.res" /w:4 /nowarn:1659;1699  "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.3.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.2.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.4.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.1.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.5.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.0.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.6.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.7.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\news\57e37c53\101bafba\App_Web_boxe1olx.8.cs"
Microsoft (R) Visual C# 2005 编译器 版本 8.00.50727.42
用于 Microsoft (R) Windows (R) 2005 Framework 版本 2.0.50727
版权所有 (C) Microsoft Corporation 2001-2005。保留所有权利。d:\vs2005\news\newsDetail.aspx(62,80): error CS0103: 当前上下文中不存在名称“Replace”
d:\vs2005\news\newsDetail.aspx(62,109): error CS0103: 当前上下文中不存在名称“vbcrlf”
d:\vs2005\news\newsDetail.aspx(63,80): error CS0103: 当前上下文中不存在名称“Replace”
d:\vs2005\news\newsDetail.aspx(63,109): error CS0103: 当前上下文中不存在名称“vbcrlf”

解决方案 »

  1.   

    <%# Replace(Eval("news_content"),vbcrlf," <br>") 
    这个错在哪儿啊,该怎么改啊???
      

  2.   

    Replace能这样用吗?是不是应该.Replace(old,new)
      

  3.   


    我是新手,不太清楚,就这个地方是个绑定数据的,该怎么改啊???
    行 62:<asp:Label ID="Label1" runat="server" Text=' <%# Replace(Eval("news_content"),vbcrlf," <br>") %>'> </asp:Label> 
      

  4.   

    cs页面写个方法
    protected string funReplae(object obj)
        {
            return obj.ToString().Replace("vbcrlf", "<br>");
        }
    这样调用
    <asp:Label ID="Label1" runat="server" Text=' <%# funReplae(Eval("news_content"))%>'> </asp:Label> 
      

  5.   


    <asp:Label ID="Label1" runat="server" ><%#DataBinder.Eval(Container.DataItem,"news_content")%></asp:Label>
      

  6.   

    Replace() 貌似没有三个参数的
      

  7.   

    呵呵,我最喜欢回答新手的问题了,
    你肯定是从asp过来的,asp.net里没有什么全局函数,全局变量了。所有的方法都包装在类里面。
    <%# Replace(Eval("news_content"),vbcrlf," <br>") 
    改为<%# Eval("news_content").ToString().Replace("\r\n","<br>")%>
      

  8.   

    你写的Replace 
    要在 newsDetail.aspx页面 的CS 去定义 一个Replace 方法 必须是公有的
      

  9.   

    <asp:Label ID="Label1" runat="server" Text='
     <%# (Eval("news_content").ToString().Replace("vbcrlf","<br>") %>'> </asp:Label>
      

  10.   

    以上问题已经解决,感谢再问:这个该怎么改???
    行 51: <asp:Button ID="Button1" runat="server" CssClass="button" Text="回上一页" OnClick="window.history.back()" />错误提示:d:\vs2005\news\newsDetail.aspx(51,59): error CS0117: “ASP.newsdetail_aspx”并不包含“window”的定义
      

  11.   

    连接好数据库,直接绑定........Eval("news_content")
      

  12.   

    <asp:Label ID="Label1" runat="server" Text=' 
    <%# (Eval("news_content").ToString().Replace("vbcrlf"," <br>") %>'> </asp:Label>
      

  13.   

    唉,好人作到底:
    <asp:Button ID="Button1" runat="server" CssClass="button" Text="回上一页" OnClick="window.history.back()" />改为<asp:Button ID="Button1" runat="server" CssClass="button" Text="回上一页" OnClientClick="window.history.back()" OnClick="定义一个服务器端的处理函数!()" />
      

  14.   

    onclick="javascript:window.history.go(-1);"
    或者在Button按扭的事件中写
    Response.write("<script language=javascript>history.go(-1);</script>)
      

  15.   

    行 51: <asp:Button ID="Button1" runat="server" CssClass="button" Text="回上一页" OnClientClick="window.history.back()" /> 
      

  16.   


    你这好象是ASP代码哟.不过,还是要谢谢各位了,问题已经解决.