c# - Gridview 工具提示不限制列文本以设置字符数量
问题描述
我在我的 gridview 上设置了一个工具提示,仅在我的第二列中显示文本的前 30 个字符,但它不起作用。我错过了什么?
protected void GridView4_RowDataBound (object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ViewState["OrigData"] = e.Row.Cells[1].Text;
if (e.Row.Cells[1].Text.Length >= 30)
{
e.Row.Cells[1].Text = e.Row.Cells[0].Text.Substring(0, 30) + "...";
e.Row.Cells[1].ToolTip = ViewState["OrigData"].ToString();
}
}
}
这是gridview的样子。我需要以“00000000000000000000000012464...等”开头的第二列仅显示前 30 个字符。
解决方案
推荐阅读
- java - 从 JSON 数组中删除对象
- python - 什么是好的做法 - 我应该创建一个新对象还是重用同一个对象?
- python - 如何从相对路径中为 pip3 模块添加前缀
- dart - 有没有一种方法可以在同一路线上以不同的方式在不同的时间显示两个小部件,一次由一个按钮控制?
- haskell - 修改可扩展记录时重叠实例
- java - 如何根据Java中的特定元素对多维对象数组进行排序
- c - 通过 SOCKS5 代理的 SSL 连接
- ios - 如何在swift4中以编程方式更改uiview的乘数高度
- mobx - 为什么 React 组件在使用observer() 包裹时会渲染两次?
- html - 如何摆脱网页上的多余空间?