我试图添加一个工具类型到我的命令按钮在我的网格视图,但我有点卡住了。
这是标记..。
<asp:CommandField ButtonType="Link" ShowEditButton="true" EditText="!" ShowDeleteButton="true" DeleteText="3" CancelText="O" ItemStyle-CssClass="View1 View2 View3" ItemStyle-Width="45px" UpdateText="P">
<ControlStyle Font-Names="'WingDings 2'" ForeColor="Black" Font-Size="16px" />
</asp:CommandField>当我在代码隐藏中断点并查看e.Row.Cells中的内容时,它是DataControlLinkButton的集合,但我似乎无法在文档中找到对此的任何引用,以查看是否可以设置tooltip。
发布于 2014-03-04 10:58:55
您可以在RowDataBound of Gridview上设置它。
我正在分享我的一个实现中的一个代码片段。
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Edit || e.Row.RowState.ToString() == "Alternate, Edit")
{
foreach (TableCell cell in e.Row.Cells)
{
if (e.Row.Cells.GetCellIndex(cell) == 4)
{
((System.Web.UI.WebControls.LinkButton)(e.Row.Cells[4].Controls[2])).ToolTip = "Tooltip goes here";
}
}
}
}
}
catch (Exception _e)
{
}
}希望这有帮助..。
https://stackoverflow.com/questions/22169839
复制相似问题