我写了个截取字符串的方法
 ///   <summary>   
    ///   截获定长的字符串   
    ///   </summary>   
    ///   <param   name="source">源字符串</param>
    ///   <param   name="length">需要截获的长度</param>   
    ///   <param   name="postfix">如果字符串被截短,需要添加什么样的后缀</param>   
    ///   <returns>截获后的字符串</returns>   
    static public string FixLenth(string source, int length, string postfix)
    {
        if (source == null)
            throw new ArgumentNullException("source");
        if (postfix == null)
            postfix = "...";        if (length < postfix.Length)
            throw new ArgumentOutOfRangeException("length");
        int postfixLength = System.Text.Encoding.GetEncoding("GB2312").GetByteCount(postfix);
        int srcLength = System.Text.Encoding.GetEncoding("GB2312").GetByteCount(source);        if (srcLength > length)
        {
            for (int i = source.Length; i > 0; i--)
            {
                srcLength = System.Text.Encoding.GetEncoding("GB2312").GetByteCount(source.Substring(0, i));                if (srcLength <= length - postfixLength)
                    return source.Substring(0, i) + postfix;
            }
            return "";
        }
        else
            return source;
    }为什么这样引用就可以
 <td width="225" class="style19" align="left"><%#Global.FixLenth(Eval("ProgramComment").ToString(), 100, "...")%></td>
但这样引用就不行,返回是空。
 <td class="style19" style="height: 100%" ><a><%#Global.FixLenth("Aam:这是一张以我们之前所打造的那种与众不同的创作风格为根基,然后在整体乐风呈现上较前作来得更加性感迷人,更加强烈震撼,甚至在歌曲表现上都显得份外深层晦暗的作品.", 20, "...")%></a></td> 

解决方案 »

  1.   

     <%#Global.FixLenth("Aam:这是一张以我们之前所打造的那种与众不同的创作风格为根基,然后在整体乐风呈现上较前作来得更加性感迷人,更加强烈震撼,甚至在歌曲表现上都显得份外深层晦暗的作品.", 20, "...")%>
    不能直接放到a里面。
      

  2.   

    <a> <%=Global.FixLenth("Aam:这是一张以我们之前所打造的那种与众不同的创作风格为根基,然后在整体乐风呈现上较前作来得更加性感迷人,更加强烈震撼,甚至在歌曲表现上都显得份外深层晦暗的作品.", 20, "...")%> </a> 
    显然对<%# %>
    <%= %>
    不了解
      

  3.   

    <%# %>是帮定数据,<%= %> 是示显.我只了解这么一点,请指教.
      

  4.   

    try this:http://download.csdn.net/source/303583