1、字段过长
1 可以直接substring 2 也可以<%# Utility.Common.GetShow( Eval("NewTitle").ToString(),20,true) %> 3 <td><%#fcwms.Common.GetContent.GetShow(Eval("com_address").ToString(), 19, true)%> </td> 4 5 6 /// <summary > 7 /// 按字节数截取字符串,中文算两个字节,全角字符算两个字节,大写字母也算两个字节 8 /// </summary > 9 /// <param name="strSrc">要处理的字符串</param> 10 /// <param name="count">要保留的字节数</param> 11 /// <param name="withPoint">设置截取后加不加省略号( "... ")默认的传true</param> 12 /// <returns></returns> 13 public static string GetStrByByteCount(string strSrc, int count, bool withPoint) 14 { 15 Regex regex = new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled); 16 char[] stringChar = strSrc.ToCharArray(); 17 StringBuilder sb = new StringBuilder(); 18 int nLength = 0; 19 bool isCut = false; 20 for (int i = 0; i < stringChar.Length; i++) 21 { 22 if ((regex.IsMatch((stringChar[i]).ToString())) || (stringChar[i] > 65280 && stringChar[i] < 65375) || (stringChar[i] > 64 && stringChar[i] < 91)) 23 { 24 nLength += 2; 25 if (nLength > count) 26 { 27 isCut = true; 28 break; 29 } 30 sb.Append(stringChar[i]); 31 } 32 else 33 { 34 nLength = nLength + 1; 35 if (nLength > count) 36 { 37 isCut = true; 38 break; 39 } 40 sb.Append(stringChar[i]); 41 } 42 43 } 44 if (isCut) 45 { 46 if (withPoint) 47 { 48 return sb.ToString() + "..."; 49 } 50 else 51 { 52 return sb.ToString(); 53 } 54 } 55 else 56 { 57 return sb.ToString(); 58 } 59 }