常用:Html Agility PackjchardetThickBoxFCKeditoreWebEditorAjaxProAspNetPager
posts - 46,  comments - 173,  trackbacks - 2
公告

我们用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 阅读(191) 评论(2) 编辑 收藏
常用:Html Agility PackjchardetThickBoxFCKeditoreWebEditorAjaxProAspNetPager