datalist绑定字段后,截取部分字段方法,加省略号

页面中:  <%#DataBinder.Eval(Container.DataItem,   "rcontent")%>  

一、  把页面换成  
   
  <%#   GetShortContent(DataBinder.Eval(Container.DataItem,   "rcontent"))%>  
   
  然后在你的Code里面写   public   string   GetShortContent(object   obj){  
  //你的字符串处理操作  
  string strtemp=obj.ToString();
        if (strtemp.Length > 10)
        {
            strtemp = strtemp.Substring(0, 10)+"...";
        }
        return strtemp;

  }

二、在提起数据的时候就:  
  select   substring(rtitle,0,10)   as   rtitle   from   你的表

select   (case   when   len(你要判断的字段)>5   then   left(你要判断的字段,5)+'......'   else   你要判断的字段   end)   from

Select    guid,      left(title,15) as title  from

原文地址:https://www.cnblogs.com/mxh691/p/1224577.html