绑定控件,设置HtmlEncode="false"即可

解决方案 »

  1.   

    html后台好像只可以用&lt的吧。不可以直接用<。就像你要输出空格得用&nbsp;一样。
    我猜的。
      

  2.   

    <asp:BoundField HtmlEncode="false"
      

  3.   


    是的~~那怎么办,runat="server"不能去掉啊
      

  4.   


    如果从后台的html编辑器里输入的,在文本框里显示就会出这种问题。直接输出到页面显示就可以了。
      

  5.   


    没有HtmlEncode这个属性啊~~我直接写上去也没反应
      

  6.   

      <asp:GridView id="x" runat="server" AutoGenerateColumns="false">
      <Columns>  
      <asp:BoundField HtmlEncode="false" DataField="你显示的字段名称" />
      </Columns>
      </asp:GridView>谁说的没有啊???
      

  7.   

    仔细看看
    http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.boundfield.htmlencode.aspx
      

  8.   

    其实我在浏览器直接看到的还是"<",可是我一查看页面的源代码它那边就显示&lt,搞到我的<a href>不能用了,直接就在页面显示了<a href> xxxx</a>,
      

  9.   


    可是我不是用<asp:BoundField>显示的啊,我直接在后台gridview.datasource=dt;然后绑定的
      

  10.   

    我贴下代码给大家看吧后台namespace excellen.tz.notice
    {
    public class db
    {
    private static  DataSet excuteds()

    string sqlds="SELECT b.nt_Title FROM EX_ReceiveNotice a INNER JOIN EX_Notice b ON a.nt_Id = b.nt_Id WHERE (a.rec_Reciver = 'chenq') AND (a.rec_Status = 0)";
    //DataSet ds= DbHelperSQL.ExecuteDataset(PubConstant.ExMainFrameConnString, CommandType.Text, sqlds);
    SqlConnection conn = new SqlConnection ("Server=.;Database=exmainframe;uid=sa;password=sa");
    DataSet ds = DbHelperSQL.ExecuteDataset(conn , CommandType.Text, sqlds);
    return ds;
    } public static  DataTable excutedt()
    {
    DataTable dt;
    string parm = "TongZhiGongGao_Receive.aspx?sessionid=&Usercode=&nt_id=";
    DataSet  ds=excuteds();
    dt=ds.Tables [0];
    //string[] temp;
    string temp = @"<a href='11.aspx'>" + ds.Tables[0].Rows[0][0].ToString() + "</a>";
    dt.Rows[0][0] = temp;
    return dt;

    }

    }
    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    GridView1.DataSource = db.excutedt();
    GridView1.DataBind(); }
    }
    }
    前台
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="excellen.tz.notice._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
    <asp:GridView ID="GridView1" runat="server" HtmlEncode="false">
    </asp:GridView>
        </div>
        </form>
    </body>
    </html>
      

  11.   

    本帖最后由 net_lover 于 2011-11-03 11:32:54 编辑
      

  12.   


    <asp:GridView ID="GridView1" runat="server" HtmlEncode="false">哪个文档写的是HtmlEncode加GridView 上的啊??
      

  13.   

    head 中去掉 runat="server"
      

  14.   

    &lt
    我试试看能不能自己编
      

  15.   

    这个你试试
    <sql id="searchSql">
    <where>
    <if test="id != null || id != ''">
    AND id LIKE CONCAT('%',#{adProvince},'%')
    </if>
    <if test="adProvince != null || adProvince != ''">
    AND adProvince LIKE CONCAT('%',#{adProvince},'%')
    </if>
    <if test="adCity != null || adCity != ''">
    AND adCity LIKE CONCAT('%',#{adCity},'%')
    </if>
    <if test="adStartTime != null || adStartTime != ''">
    AND adStartTime &gt;= #{adStartTime}
    </if>
    <if test="adEndTime != null || adEndTime != ''">
    AND adEndTime &lt;= #{adStartTime}
    </if>
    <if test="adStatus != null || adStatus != ''">
    AND adStatus = #{adStatus}
    </if>
    </where>
    </sql>