鼠标悬停时如何在gridview行中显示工具提示文本?
问题描述:
如何在鼠标悬停时在gridview行中显示工具提示文本?
How to show tooltip text in gridview row on mouseover?
答
您需要为此使用GridView的 RowDataBound .
You need to use RowDataBound of GridView for this.
protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
DataControlRowType rtype = e.Row.RowType;
if (rtype == DataControlRowType.DataRow && rtype != DataControlRowType.Footer
&& rtype != DataControlRowType.Separator && rtype != DataControlRowType.Header
&& rtype != DataControlRowType.Pager)
{
//Highlight Row
//e.Row.Attributes.Add("onmouseover", "Highlight(this,'#DCEDFF');");
//ShowToolTip
e.Row.ToolTip = "This text needs to shown on mouseover of the row!";
}
}
<asp:menu id="Menu1" runat="server" backcolor="#F7F6F3" xmlns:asp="#unknown">
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#7C6F57" StaticSubMenuIndent="10px"
style="z-index: 1; left: 78px; top: 85px; position: absolute; height: 34px; width: 78px">
<staticselectedstyle backcolor="#5D7B9D" />
<staticmenuitemstyle horizontalpadding="5px" verticalpadding="2px" />
<dynamichoverstyle backcolor="#7C6F57" forecolor="White" />
<dynamicmenustyle backcolor="#F7F6F3" />
<dynamicselectedstyle backcolor="#5D7B9D" />
<dynamicmenuitemstyle horizontalpadding="5px" verticalpadding="2px" />
<statichoverstyle backcolor="#7C6F57" forecolor="White" />
<items>
<%--<asp:menuitem popoutimageurl="~/IMAGES/Chrysanthemum.jpg" text="HOME" value="0">
<asp:menuitem navigateurl="~/Default2.aspx">
PopOutImageUrl="~/IMAGES/Chrysanthemum.jpg" Text="ABOUT US" Value="1">
</asp:menuitem>
<asp:menuitem text="CAREERS" value="2"></asp:menuitem>
</asp:menuitem>--%>
<asp:menuitem text="CLIENTS" value="4"></asp:menuitem>
</items>
</asp:menu>
有关特定列上自定义工具提示的信息,请单击以下文章.
http://www.dotnettwitter.com/2010/11/showing- tooltip-with-some-data-from.html [ ^ ]
For custom tooltip on a particular column for each row on mouse over of gridview row, you can refer the following post.
http://www.dotnettwitter.com/2010/11/showing-tooltip-with-some-data-from.html[^]