首页 > 其他分享 >Gridview的tooltip功能

Gridview的tooltip功能

时间:2022-12-14 15:47:28浏览次数:30  
标签:功能 Gridview Text Cells tooltip 35 RowDataBound Row

gridview提供了tooltip功能,当鼠标移动到下发内容单元格时,会把所有内容都给显示出来。

效果图如下 :

 

 在具体实现上,只需要在RowDataBound事件中写上一段代码即可:

 protected void GridViewEx_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
        if (e.Row.Cells[8].Text.Length > 35)
        {
           e.Row.Cells[8].ToolTip = e.Row.Cells[8].Text;
           e.Row.Cells[8].Text = e.Row.Cells[8].Text.Substring(0, 35) + "...";
        }
    }
 }

 

标签:功能,Gridview,Text,Cells,tooltip,35,RowDataBound,Row
From: https://www.cnblogs.com/lgx5/p/16982329.html

相关文章