Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将工具提示添加到CommandField ButtonType=";链接“;_C#_Asp.net_Gridview - Fatal编程技术网

C# 将工具提示添加到CommandField ButtonType=";链接“;

C# 将工具提示添加到CommandField ButtonType=";链接“;,c#,asp.net,gridview,C#,Asp.net,Gridview,我正在尝试向gridview上的命令按钮添加工具类型,但我有点卡住了 这是标记 <asp:CommandField ButtonType="Link" ShowEditButton="true" EditText="&#x21" ShowDeleteButton="true" DeleteText="&#x33;" CancelText="&#x4F" ItemStyle-CssClass="View1 View2 View3" ItemStyle-Width="4

我正在尝试向gridview上的命令按钮添加工具类型,但我有点卡住了

这是标记

<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
中的内容时,它是
DataControlInkButton
的集合,但我似乎在文档中找不到对此的任何引用,以查看是否有
工具提示可以设置。

您可以在
Gridview
RowDataBound
上设置它

我正在共享我的一个实现的代码片段

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)
        {
        }
    }

希望这有帮助。

我看了一个@EdWindeking,但那是按钮类型是图像,而不是链接的地方谢谢。。。我有点傻,没有意识到DataControlLinkButton实际上是一个LinkButton:doh: