• 企业400电话
  • 网络优化推广
  • AI电话机器人
  • 呼叫中心
  • 全 部 栏 目

    网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    关于中gridview 字符串截取的方法
    POST TIME:2021-10-18 02:53

    首先在前台设置样式

    复制代码 代码如下:

    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; 

           } 
       } 
     

    上一篇:aspxgridview CustomButtonCallback 不支持弹出消息提示解决方法
    下一篇:c#实现根据网络IP显示地理位置功能示例
  • 相关文章
  • 

    关于我们 | 付款方式 | 荣誉资质 | 业务提交 | 代理合作


    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    X

    截屏,微信识别二维码

    微信号:veteran88

    (点击微信号复制,添加好友)

     打开微信