前台: <%#getString((string)(DataBinder.Eval(Container.DataItem, "title ")),20)%> 后台: protected string getString(string StringInput,int StringLength) { if(StringInput== " "||StringInput==null) return " "; string tempTitle= " "; if(StringInput.Length> StringLength) tempTitle = StringInput.Substring(0,StringLength)+ "... "; else if(StringInput.Length==StringLength) tempTitle = StringInput; else { for(int i=0;i <StringLength-StringInput.Length;i++) { StringInput = StringInput+ " "; tempTitle=StringInput; } } return tempTitle; }