後臺方法: /// <summary> /// 截取字符串 /// </summary> /// <param name="str">要截取的字符串</param> /// <param name="c">保留長度</param> /// <returns>截取後的字符串</returns> protected string pd_str(string str, int c) { if (str.Length > c) { str = str.Substring(0, c) + "..."; } return str; }頁面調用:在對應位置<%#pd_str(Eval("要截取的字符串").ToString(),長度)%>