读书人

截取固定长度字符串显示在页面多余部

发布时间: 2012-01-26 19:40:46 作者: rapoo

截取固定长度字符串显示在页面,多余部分显示为省略号(区分汉字和字符)
databinder(?)
?里怎么写?

[解决办法]
要是dataGrid 的话,你可以写在DataBinding事件中

if(e.Item.Cells[0].Text.Length > 20)
{
e.Item.Cells[0].Text = e.Item.Cells[0].Text.SubString(0,20) + "... ";
}

读书人网 >asp.net

热点推荐