【问题标题】:How to display Tooltip on GridView Row Hover如何在 GridView 行悬停上显示工具提示
【发布时间】:2012-10-20 16:40:36
【问题描述】:

当鼠标放在 GridView Row (onmouseover) 上时,我需要显示一个工具提示 我需要在GridView_RowData中动态设置Tooltip内容@

我该怎么做??

我可以在e.Row.Attributes.Add(... 中这样做吗??

【问题讨论】:

标签: c# asp.net gridview hover tooltip


【解决方案1】:

这样试试吧……

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        //use this way
        e.Row.ToolTip = "My FooBar tooltip";
         //or use this way
        e.Row.Attributes.Add("title", "My FooBar tooltip");
    }
 }

这将显示整行的工具提示。如果您需要在特定控件上显示,然后找到该控件并将 Tooltip 属性设置为您自己的标题...

【讨论】:

    【解决方案2】:

    可以这样完成。这是工作副本。

    您需要做的是,您必须在Gridview OnRowDataBound 事件中找到控件(要为其显示tooltip on hover of mouse)并将tooltip 文本分配给控件。

    protected void GridDepartment_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label LabelCoachName = e.Row.FindControl("LabelCoachName") as Label;
            LabelCoachName.ToolTip = LabelCoachName.Text;
        }
    }
    

    【讨论】:

      【解决方案3】:

      试试这个

          If e.Row.RowType = DataControlRowType.DataRow Then
              'your dynamic data fill to e.row.tooltip
              e.Row.ToolTip = e.Row.Cells(1).Text & "-" & e.Row.Cells(3).Text
          End If
      

      【讨论】:

        猜你喜欢
        • 2012-06-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-29
        • 2022-08-03
        • 2021-10-02
        相关资源
        最近更新 更多