zoukankan      html  css  js  c++  java
  • gridview 截取字符串

    在Gridview中,如果你的某一列字符串的长度过长,不做处理的话.那么将显示的奇丑无比,

    可以采取设置样式,将其显示为定长,可以在点击查看的时候,在另一个页面对其进行显示

    首先在前台设置样式

    [c-sharp] view plaincopy
     
    1. <style  type="text/css">  
    2.  .listover150  
    3. {  
    4. 150px;  
    5. text-align:left;  
    6. overflow:hidden;  
    7. text-overflow:ellipsis;//超长设置省略号  
    8. white-space:nowrap;  
    9. }  
    10. </style>  

    然后在后台GridView中的RowDataBind中进行设置

    ,附带几句可以改变鼠标移动的样式设置

    [c-sharp] view plaincopy
     
    1. //列表加载处理  
    2.    protected void gv_showReport_RowDataBound(object sender, GridViewRowEventArgs e)  
    3.    {  
    4.   
    5.        if (e.Row.RowType == DataControlRowType.DataRow)  
    6.        {  
    7.   
    8.            //当鼠标移开时还原背景色  
    9.            e.Row.Attributes.Add("onmouseout""this.style.backgroundColor=c");  
    10.            e.Row.Attributes.Add("onmouseover""c=this.style.backgroundColor;this.style.backgroundColor='#F4FBFF'");  
    11.            e.Row.Attributes.Add("onclick""this.style.backgroundColor='#e2eaf1'");  
    12.        }  
    13.        if (e.Row.RowType == DataControlRowType.Header)  
    14.        {  
    15.            e.Row.Attributes.Add("style""background-image:url('../images/grid3-hrow.gif')");  
    16.        }  
    17.        if (e.Row.RowType == DataControlRowType.DataRow)  
    18.        {  
    19.            //设置申请原因字符串显示长度  
    20.            string strDISC = e.Row.Cells[4].Text.Trim();  
    21.            e.Row.Cells[4].Text = "<div class=/"listover150/">" + strDISC + "</div>";  
    22.            e.Row.Cells[4].ToolTip = strDISC;//鼠标放上去显示所有  
    23.   
    24.            //设置审批备注字符串截取长度  
    25.            string str = e.Row.Cells[7].Text.Trim();  
    26.            e.Row.Cells[7].Text = "<div class=/"listover150/">" + str + "</div>";  
    27.            e.Row.Cells[7].ToolTip = str;  
    28.   
    29.   
    30.               
    31.        }  
    32.    }  
  • 相关阅读:
    Kafk为什么这么快
    kafka消息格式演变
    kafka基础命令及api使用
    zookeeper && kafka && kafka manager开机自启动设置
    sqoop进行将Hive 词频统计的结果数据传输到Mysql中
    hive实例的使用
    使用HBase Shell命令
    Hadoop使用实例 词频统计和气象分析
    HDFS 操作命令
    第四次作业 描述HDFS体系结构、工作原理与流程
  • 原文地址:https://www.cnblogs.com/withoutaword/p/3149309.html
Copyright © 2011-2022 走看看