首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向CommandField ButtonType = "Link“添加工具提示

向CommandField ButtonType = "Link“添加工具提示
EN

Stack Overflow用户
提问于 2014-03-04 10:50:23
回答 1查看 1.2K关注 0票数 0

我试图添加一个工具类型到我的命令按钮在我的网格视图,但我有点卡住了。

这是标记..。

代码语言:javascript
复制
<asp:CommandField ButtonType="Link" ShowEditButton="true" EditText="&#x21" ShowDeleteButton="true" DeleteText="&#x33;" CancelText="&#x4F" ItemStyle-CssClass="View1 View2 View3" ItemStyle-Width="45px" UpdateText="&#x50">
    <ControlStyle Font-Names="'WingDings 2'" ForeColor="Black" Font-Size="16px" />
</asp:CommandField>

当我在代码隐藏中断点并查看e.Row.Cells中的内容时,它是DataControlLinkButton的集合,但我似乎无法在文档中找到对此的任何引用,以查看是否可以设置tooltip

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-04 10:58:55

您可以在RowDataBound of Gridview上设置它。

我正在分享我的一个实现中的一个代码片段。

代码语言:javascript
复制
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)
        {
        }
    }

希望这有帮助..。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22169839

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档