方法一://在調用後臺函數
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>