關(guān)于中g(shù)ridview 字符串截取的方法
更新時間:2013年06月22日 10:28:57 作者:
在Gridview中,如果你的某一列字符串的長度過長,不做處理的話.那么將顯示的奇丑無比,可以采取設(shè)置樣式,將其顯示為定長,可以在點擊查看的時候,在另一個頁面對其進行顯示
首先在前臺設(shè)置樣式
復(fù)制代碼 代碼如下:
<style type="text/css">
.listover150
{
width:150px;
text-align:left;
overflow:hidden;
text-overflow:ellipsis;//超長設(shè)置省略號
white-space:nowrap;
}
</style>
然后在后臺GridView中的RowDataBind中進行設(shè)置
,附帶幾句可以改變鼠標(biāo)移動的樣式設(shè)置
復(fù)制代碼 代碼如下:
//列表加載處理
protected void gv_showReport_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//當(dāng)鼠標(biāo)移開時還原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F4FBFF'");
e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#e2eaf1'");
}
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Attributes.Add("style", "background-image:url('../images/grid3-hrow.gif')");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
//設(shè)置申請原因字符串顯示長度
string strDISC = e.Row.Cells[4].Text.Trim();
e.Row.Cells[4].Text = "<div class=/"listover150/">" + strDISC + "</div>";
e.Row.Cells[4].ToolTip = strDISC;//鼠標(biāo)放上去顯示所有
//設(shè)置審批備注字符串截取長度
string str = e.Row.Cells[7].Text.Trim();
e.Row.Cells[7].Text = "<div class=/"listover150/">" + str + "</div>";
e.Row.Cells[7].ToolTip = str;
}
}
相關(guān)文章
ASP.NET Core讀取Request.Body的正確方法
相信大家在使用ASP.NET Core進行開發(fā)的時候,肯定會涉及到讀取Request.Body的場景,畢竟我們大部分的POST請求都是將數(shù)據(jù)存放到Http的Body當(dāng)中,本文就介紹一下ASP.NET Core讀取Request.Body,感興趣的可以了解一下2021-05-05ASP.net中網(wǎng)站訪問量統(tǒng)計方法代碼
這篇文章介紹了ASP.net中網(wǎng)站訪問量統(tǒng)計方法代碼,有需要的朋友可以參考一下2013-11-11.NET?core項目AsyncLocal在鏈路追蹤中的應(yīng)用
這篇文章主要為大家介紹了.NET?core項目zhong?AsyncLocal在鏈路追蹤中的應(yīng)用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-05-05為TextBox裝飾水印與(blur和focus)事件應(yīng)用
為了界面的美觀,有些時候可能需要為文本框(TextBox)裝飾個水印;它有兩種狀態(tài),一是blur和focus。因此,我們可以在Javascript寫兩個事件,感興趣的朋友可以了解下2013-01-01