How to set ellipses on a column data if it exceeds more than a set record

后端 未结 2 404
清酒与你
清酒与你 2021-01-07 08:24

How to set ellipses on a column data

I have the following BoundField in my GridView:



        
2条回答
  •  旧时难觅i
    2021-01-07 08:39

    text-overflow:ellipsis; only works if the the following properties are true:

    The element's width must be specified. The element must have overflow:hidden and white-space:nowrap set. Change your css like below

    .hideText  {
        width:120px;
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
     }
    

    Here is the working Demo

    Update:

    Here is your complete TemplateField definition. Define a div within the TemplateField and decorate with the css properties for ellipsis.

     
         
              

    Here is how it looks like when I tried this in a gridview locally.

    enter image description here

提交回复
热议问题