Gridview中,若是你的某一列字符串的長度過長,不作處理的話.那麼將顯示的奇醜無比,css
能夠採起設置樣式,將其顯示爲定長,能夠在點擊查看的時候,在另外一個頁面對其進行顯示this
首先在前臺設置樣式url
<style type="text/css"> .listover150 { width:150px; text-align:left; overflow:hidden; text-overflow:ellipsis;//超長設置省略號 white-space:nowrap; } </style>
而後在後臺GridView中的RowDataBind中進行設置spa
,附帶幾句能夠改變鼠標移動的樣式設置blog
//列表加載處理 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; } }