方法1:★css处理:

a
{
 width: 80px;
 overflow: hidden; /*注意不要写在最后了*/
 white-space: nowrap;
 -o-text-overflow: ellipsis;
 text-overflow: ellipsis;
}
a:hover
{
 text-decoration: none;
 color: #000;
}

<a href="#" style="display:block; ;text-decoration: none; color: #000;" title='<%#Eval("GlobalCode")%>'><%#Eval("GlobalCode")%></a>

方法2:★服务器端截取字符

在GridViewTicket_RowDataBound等事件中:

string hotelAddress = dtHotel.Rows[row.RowIndex]["hotel_address"].ToString().Trim();
if (hotelAddress.Length > 9)
{
       ((Label)row.FindControl("LabelHotelAddress")).Text = hotelAddress.Substring(0, 8) + "...";
       ((Label)row.FindControl("LabelHotelAddress")).ToolTip = hotelAddress;
 }
else
{
       ((Label)row.FindControl("LabelHotelAddress")).Text = hotelAddress;
        ((Label)row.FindControl("LabelHotelAddress")).ToolTip = hotelAddress;
}

相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2021-12-02
  • 2022-12-23
  • 2021-09-28
  • 2021-09-21
  • 2021-12-01
  • 2022-02-06
猜你喜欢
  • 2022-12-23
  • 2021-05-26
  • 2022-02-19
  • 2022-02-18
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
相关资源
相似解决方案