国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

關于中gridview 字符串截取的方法

2024-07-10 12:45:14
字體:
來源:轉載
供稿:網友

首先在前臺設置樣式
代碼如下:
<style  type="text/css"> 
 .listover150 

width:150px; 
text-align:left; 
overflow:hidden; 
text-overflow:ellipsis;//超長設置省略號 
white-space:nowrap; 

</style> 

然后在后臺GridView中的RowDataBind中進行設置

,附帶幾句可以改變鼠標移動的樣式設置

  代碼如下:
 //列表加載處理 
   protected void gv_showReport_RowDataBound(object sender, GridViewRowEventArgs e) 
   { 

       if (e.Row.RowType == DataControlRowType.DataRow) 
       { 

           //當鼠標移開時還原背景色 
           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) 
       { 
           //設置申請原因字符串顯示長度 
           string strDISC = e.Row.Cells[4].Text.Trim(); 
           e.Row.Cells[4].Text = "<div class=/"listover150/">" + strDISC + "</div>"; 
           e.Row.Cells[4].ToolTip = strDISC;//鼠標放上去顯示所有 

           //設置審批備注字符串截取長度 
           string str = e.Row.Cells[7].Text.Trim(); 
           e.Row.Cells[7].Text = "<div class=/"listover150/">" + str + "</div>"; 
           e.Row.Cells[7].ToolTip = str; 

       } 
   } 
 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嘉义县| 商水县| 鄂托克旗| 玉树县| 高密市| 镇康县| 苍溪县| 彝良县| 崇州市| 邯郸市| 扎赉特旗| 柘城县| 阜阳市| 衡山县| 鹰潭市| 巴林左旗| 屏边| 南充市| 肇州县| 民丰县| 桂平市| 兴安盟| 揭阳市| 博客| 虹口区| 清镇市| 台南县| 西藏| 南和县| 云和县| 镇平县| 泗阳县| 开鲁县| 东乡| 河源市| 崇明县| 横峰县| 山丹县| 潞城市| 宁明县| 宁陕县|