我希望 HyperLinkField 中有一个 ToolTip 字段,因为 HyperLink 中有一个。
在绑定(bind)到我的数据源之前,我正在通过代码创建一个 HyperLinkField:
HyperLinkField hl = new HyperLinkField();
hl.DataNavigateUrlFields = new string[] { "col" };
hl.DataNavigateUrlFormatString = "{0}";
hl.DataTextField = "Foo";
有什么方法可以为将呈现为工具提示(或替代文本)的内容设置值?
任何帮助将不胜感激。
最佳答案
您的需求可以在<asp:HyperlinkField>
中完成通过在 RowDataBound
中为该特定单元格添加工具提示本身GridView
的事件.将 GridView 绑定(bind)到您的 DataSource 后,您可以在 RowDataBound
中执行此操作。事件如下:
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].ToolTip = "Your tooltip text";
}
虽然您已经接受了另一个答案,但我的回答可能对其他一些用户有帮助!
关于asp.net HyperLinkField 没有 ToolTip 属性(替代文本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/803725/