(DataBinder.Eval(Container.DataItem,"title")).Substring(0,10) + "...."

解决方案 »

  1.   

    或者你codebehind写个截取字符窜的函数
    然后前台调用
      

  2.   

    public static string  CutText(string Str,int Length)
    {
    //初始化
    int i = 0, j = 0;

    //去除html代码
    Str = Regex.Replace(Str,@"\<[^\<^\>]*\>","");
    Str = Str.Replace("&nbsp;","");
    //为汉字或全脚符号长度加2否则加1
    foreach (char Char in Str)
    {
    if ((int)Char > 127)
    {
    i += 2;
    }
    else
    {
    i ++;
    }
    if (i > Length)
    {
    Str = Str.Substring(0, j) + "...";
    break;
    }
    j ++;
    }
    return Str;
    }前台:
    <%# CutText((string)DataBinder.Eval(Container.DataItem, "TextTitle"),10)%>
      

  3.   

    using System.Text.RegularExpressions;
    引用正则表达式