• 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.    }  
  • 相关阅读:
    常遇问题及解决
    cs231笔记1
    scikit-learn模型参数保存和多分类策略(one vs one和one vs rest)
    练习1_scikit_learn自带数据集_sklearn和svm
    记一次连不上wifi网的处理
    剑指offer | 从1到n整数中1出现的次数 | 22
    剑指offer | 数组中出现次数超过一半的数字 | 21
    剑指offer | 不用加减乘除做加法 | 20
    剑指offer | 二进制中1的个数 | 19
    剑指offer | 链表中环的入口结点 | 18
  • 原文地址:https://www.cnblogs.com/withoutaword/p/3149309.html
Copyright © 2020-2023  润新知