repeater 字段过长

可以直接substring

也可以<%# Utility.Common.GetShow( Eval("NewTitle").ToString(),20,true) %>
  <td><%#fcwms.Common.GetContent.GetShow(Eval("com_address").ToString(), 19, true)%> </td> /// <summary > /// 按字节数截取字符串,中文算两个字节,全角字符算两个字节,大写字母也算两个字节 /// </summary > /// <param name="strSrc">要处理的字符串</param> /// <param name="count">要保留的字节数</param> /// <param name="withPoint">设置截取后加不加省略号( "... ")默认的传true</param> /// <returns></returns> public static string GetStrByByteCount(string strSrc, int count, bool withPoint) { Regex regex = new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled); char[] stringChar = strSrc.ToCharArray(); StringBuilder sb = new StringBuilder(); int nLength = 0; bool isCut = false; for (int i = 0; i < stringChar.Length; i++) { if ((regex.IsMatch((stringChar[i]).ToString())) || (stringChar[i] > 65280 && stringChar[i] < 65375) || (stringChar[i] > 64 && stringChar[i] < 91)) { nLength += 2; if (nLength > count) { isCut = true; break; } sb.Append(stringChar[i]); } else { nLength = nLength + 1; if (nLength > count) { isCut = true; break; } sb.Append(stringChar[i]); } } if (isCut) { if (withPoint) { return sb.ToString() + "..."; } else { return sb.ToString(); } } else { return sb.ToString(); } }

 方法1:

 <td><asp:Label ID="Label14" runat="server" Text='<%# fcwms.Common.GetContent.GetShow(Eval("com_address").ToString(),19,true)%>'  ToolTip='<%# Eval("com_address")%>'></asp:Label></td>

 方法2:

<td><asp:Label ID="lblMatNM" runat="server" Text='<%#Eval("matNM").ToString().Length >10?Eval ("matNM").ToString().Substring (0,10)+"...":Eval ("matNM").ToString ()%>' ToolTip ='<%#Eval("matNM")%>'></asp:Label></td>

 无提示:

<td><%#fcwms.Common.GetContent.GetShow(Eval("com_address").ToString(),19,true)%></td>

 

你可能感兴趣的:(字段)