About the gridview string interception method in

  • 2020-06-12 08:50:56
  • OfStack

Start by setting the style in the foreground


<style  type="text/css">  
 .listover150  
{  
width:150px;  
text-align:left;  
overflow:hidden;  
text-overflow:ellipsis;// Extra-long ellipsis setting   
white-space:nowrap;  
}  
</style>  

It is then set in RowDataBind in the background GridView

, with a few sentences to change the mouse movement style Settings


 // List loading processing   
   protected void gv_showReport_RowDataBound(object sender, GridViewRowEventArgs e)  
   {  

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

           // Restores the background color when the mouse is moved   
           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)  
       {  
           // Sets the display length of the request reason string   
           string strDISC = e.Row.Cells[4].Text.Trim();  
           e.Row.Cells[4].Text = "<div class=/"listover150/">" + strDISC + "</div>";  
           e.Row.Cells[4].ToolTip = strDISC;// Mouse up to show all   

           // Sets the length of the approval remark string interception   
           string str = e.Row.Cells[7].Text.Trim();  
           e.Row.Cells[7].Text = "<div class=/"listover150/">" + str + "</div>";  
           e.Row.Cells[7].ToolTip = str;  

       }  
   }  
 


Related articles: