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)
protected void GVShareHolder_RowDataBound(object sender, GridViewRowEventArgs e)
 {
    {
 if (e.Row.RowType == DataControlRowType.DataRow)
        if (e.Row.RowType == DataControlRowType.DataRow)
 {
        {
 try
            try
 {
            {
 HyperLink lbLName = (HyperLink)e.Row.FindControl("HLCID");
                HyperLink lbLName = (HyperLink)e.Row.FindControl("HLCID");
 Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");
                Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");

 lbLName.Attributes.Add("onmouseover", "TagToTip('" + lbLT2TBalloon.ClientID + "', BALLOON, true, FADEIN, 400, FADEOUT, 400, ABOVE,true, WIDTH, 260, PADDING, 8, TEXTALIGN, 'left', OFFSETX, -10)");
                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)
            catch (Exception)
 {
            {

 throw;
                throw;
 }
            }
 }
        }
 }
    }
 
/*
 protected void gvEvents_RowDataBound(object sender, GridViewRowEventArgs e)
protected void gvEvents_RowDataBound(object sender, GridViewRowEventArgs e)
 {
    {
 if (e.Row.RowType == DataControlRowType.DataRow)
        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("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.Add("onMouseOut", "this.style.backgroundColor=currentbackgroundcolor;this.style.color=currentcolor");
 e.Row.Attributes["style"] = "cursor:hand";
            e.Row.Attributes["style"] = "cursor:hand";
 try
            try
 {
            {
 Label lbLName = (Label)e.Row.FindControl("LabelUserName");
                Label lbLName = (Label)e.Row.FindControl("LabelUserName");
 Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");
                Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");

 lbLName.Attributes.Add("onmouseover", "TagToTip('" + lbLT2TBalloon.ClientID + "', BALLOON, true, FADEIN, 400, FADEOUT, 400, ABOVE,true, WIDTH, 260, PADDING, 8, TEXTALIGN, 'left', OFFSETX, -10)");
                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)
            catch (Exception)
 {
            {

 throw;
                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>
在后台代码中加入这个方法
 protected void GVShareHolder_RowDataBound(object sender, GridViewRowEventArgs e)
protected void GVShareHolder_RowDataBound(object sender, GridViewRowEventArgs e) {
    { if (e.Row.RowType == DataControlRowType.DataRow)
        if (e.Row.RowType == DataControlRowType.DataRow) {
        { try
            try {
            { HyperLink lbLName = (HyperLink)e.Row.FindControl("HLCID");
                HyperLink lbLName = (HyperLink)e.Row.FindControl("HLCID"); Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");
                Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");
 lbLName.Attributes.Add("onmouseover", "TagToTip('" + lbLT2TBalloon.ClientID + "', BALLOON, true, FADEIN, 400, FADEOUT, 400, ABOVE,true, WIDTH, 260, PADDING, 8, TEXTALIGN, 'left', OFFSETX, -10)");
                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)
            catch (Exception) {
            {
 throw;
                throw; }
            } }
        } }
    }
/*
 protected void gvEvents_RowDataBound(object sender, GridViewRowEventArgs e)
protected void gvEvents_RowDataBound(object sender, GridViewRowEventArgs e) {
    { if (e.Row.RowType == DataControlRowType.DataRow)
        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("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.Add("onMouseOut", "this.style.backgroundColor=currentbackgroundcolor;this.style.color=currentcolor"); e.Row.Attributes["style"] = "cursor:hand";
            e.Row.Attributes["style"] = "cursor:hand"; try
            try {
            { Label lbLName = (Label)e.Row.FindControl("LabelUserName");
                Label lbLName = (Label)e.Row.FindControl("LabelUserName"); Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");
                Label lbLT2TBalloon = (Label)e.Row.FindControl("T2TBalloon");
 lbLName.Attributes.Add("onmouseover", "TagToTip('" + lbLT2TBalloon.ClientID + "', BALLOON, true, FADEIN, 400, FADEOUT, 400, ABOVE,true, WIDTH, 260, PADDING, 8, TEXTALIGN, 'left', OFFSETX, -10)");
                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)
            catch (Exception) {
            {
 throw;
                throw; }
            } }
        } }
    }
第二种方法 可以直接在模板列中加他的属性 ToolTip= '<%# Eval("RunScope") + "\n\t"%>'
 
                    
                     
                    
                 
                    
                 
 
    
 
         
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号