现在的位置: 首页 > 综合 > 正文

截取字符串

2014年03月07日 ⁄ 综合 ⁄ 共 348字 ⁄ 字号 评论关闭

public string FormatTitleLength(string s)
{
  return s.Length>20 ? s.SubString(0,20)+"..." : s;
}

在帮定的时候用模版列
<asp:TemplateColumn>
      <ItemStyle Font-Names="宋体" HorizontalAlign="Left" Width="420px"></ItemStyle>
      <ItemTemplate>
        <%# FormatTitleLength(DataBinder.Eval Container, "DataItem.article_title").ToString())%>
      </ItemTemplate>
    </asp:TemplateColumn>

抱歉!评论已关闭.