常用搜索: 北大青鸟系统分析师数据库系统工程师网络工程师软件设计师软件评测师信息安全工程师程序员网络管理员短信猫OracleSQL ServerDB2AndroidWindows操作系统

我们用Repeater生成一些列表时,对于一些较长的内容一般只会显示部分的信息,如只显示20个字。
我是用以下方法实现的:


在.aspx中

<%# GenDescription(DataBinder.Eval(Container.DataItem,"Description"),20)%>




在.cs中

public string GenDescription(string description,int len)
        
{
            
if(description.Length==0)
            
{
                
return "";
            }

            
else if(description.Length>len)
            
{
                
return description.Substring(0,len)+"";
            }

            
else
            
{
                
return description;
            }

        }

posted on 2007-10-27 16:38  Bankey  阅读(336)  评论(2编辑  收藏  举报
常用插件:Html Agility PackjchardetThickBoxFCKeditoreWebEditorAjaxProAspNetPager