DataGrid控制显示字符的长度

来源:互联网 发布:淘宝白菜网站 编辑:程序博客网 时间:2024/05/21 18:50

方法一://在调用后台函数
public string GetSubString(string strinput)
{
   if(strinput.lenght>50)
   {
         return strinput.substring(0,30) + "...";
   }
   else
   {
         return strinput.tostring();
   }
}


//***调用函数
<asp:lable id=lblCaption runat=server Text='<%# GetSubString(DataBinder.Eval 
(Container.DataItem,"Catption").ToString())%>'

 

 
 
 
方法二:样式表控制: 超过字段用"....."替换
.grid
{
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;

 

方法三:自动换行:CSS控制
<style type="text/css">
.HuanHang{WORD-BREAK:break-all;}
</style> 

 
方法四:<DIV STYLE="width: 120px; height: 50px; border: 1px solid blue; 
            overflow: hidden; text-overflow:ellipsis"> 
<NOBR>就是比如有一行文字,很长,表格内一行显示不下.</NOBR> 
</DIV>
 

原创粉丝点击