Gridview 列的绑定 实现 ToolTip功能
第一种方法 引入javascript脚本库
在你的内容区加上
<script type="text/javascript" src="~/Script/wz_tooltip.js"></script>
<script type="text/javascript" src="~/Script/tip_balloon.js"></script>
<script type="text/javascript" src="~/Script/tip_centerwindow.js"></script>
将列转化成模板列 加入
<asp:HyperLink ID="HLCID" runat="server" NavigateUrl='<%# "javascript:OpenWindow(\"~/GetShopCard.aspx?o=View&sid="+Eval("SID").ToString()+"\");" %>' Text='<%# Bind("CardID") %>' onmouseover="TagToTip('T2TBalloon', BALLOON, true, FADEIN, 400, FADEOUT, 400, ABOVE,true, WIDTH, 260, PADDING, 8, TEXTALIGN, 'left', OFFSETX, -10)" />
<asp:Label runat="server" id="T2TBalloon" style="display:none"><%= Resources.Companys.ShopRunScope %><b><%# Eval("RunScope") + "\n\t"%></b><br /><%=Resources.Companys.ShopPlace %><b><%# Eval("Place")%></b> </asp:Label>
在后台代码中加入这个方法
protected void GVShareHolder_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
try
{
HyperLink lbLName = (HyperLink)e.Row.FindControl("HLCID");
Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");
![](/Images/OutliningIndicators/InBlock.gif)
lbLName.Attributes.Add("onmouseover", "TagToTip('" + lbLT2TBalloon.ClientID + "', BALLOON, true, FADEIN, 400, FADEOUT, 400, ABOVE,true, WIDTH, 260, PADDING, 8, TEXTALIGN, 'left', OFFSETX, -10)");
}
catch (Exception)
{
![](/Images/OutliningIndicators/InBlock.gif)
throw;
}
}
}
/*
protected void gvEvents_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onMouseOver", "currentbackgroundcolor=this.style.backgroundColor;currentcolor=this.style.color;this.style.backgroundColor='red';this.style.color='white'");
e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=currentbackgroundcolor;this.style.color=currentcolor");
e.Row.Attributes["style"] = "cursor:hand";
try
{
Label lbLName = (Label)e.Row.FindControl("LabelUserName");
Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");
![](/Images/OutliningIndicators/InBlock.gif)
lbLName.Attributes.Add("onmouseover", "TagToTip('" + lbLT2TBalloon.ClientID + "', BALLOON, true, FADEIN, 400, FADEOUT, 400, ABOVE,true, WIDTH, 260, PADDING, 8, TEXTALIGN, 'left', OFFSETX, -10)");
}
catch (Exception)
{
![](/Images/OutliningIndicators/InBlock.gif)
throw;
}
}
}
*/
第二种方法 可以直接在模板列中加他的属性 ToolTip= '<%# Eval("RunScope") + "\n\t"%>'
第一种方法 引入javascript脚本库
在你的内容区加上
<script type="text/javascript" src="~/Script/wz_tooltip.js"></script>
<script type="text/javascript" src="~/Script/tip_balloon.js"></script>
<script type="text/javascript" src="~/Script/tip_centerwindow.js"></script>
将列转化成模板列 加入
<asp:HyperLink ID="HLCID" runat="server" NavigateUrl='<%# "javascript:OpenWindow(\"~/GetShopCard.aspx?o=View&sid="+Eval("SID").ToString()+"\");" %>' Text='<%# Bind("CardID") %>' onmouseover="TagToTip('T2TBalloon', BALLOON, true, FADEIN, 400, FADEOUT, 400, ABOVE,true, WIDTH, 260, PADDING, 8, TEXTALIGN, 'left', OFFSETX, -10)" />
<asp:Label runat="server" id="T2TBalloon" style="display:none"><%= Resources.Companys.ShopRunScope %><b><%# Eval("RunScope") + "\n\t"%></b><br /><%=Resources.Companys.ShopPlace %><b><%# Eval("Place")%></b> </asp:Label>
在后台代码中加入这个方法
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
/*
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
第二种方法 可以直接在模板列中加他的属性 ToolTip= '<%# Eval("RunScope") + "\n\t"%>'