Bind a tooltip gridview Column

Source: Internet
Author: User
Bind the gridview column to implement the tooltip Function

Method 1 introduce the Javascript script Library

Add
<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_center1_1_js "> </SCRIPT>

Convert columns into template columns and add them
<ASP: hyperlinkId = "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, abve, true,Width: 260, Padding, 8, textalign, 'left', offsetx,-10) "/>

<ASP: LabelRunat = "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>

In the backgroundCodeAdd this method

Protected   Void Gv1_holder_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 " );

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

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 " );

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

Throw;
}
}
}

*/

The second method can directly add the tooltip = '<% # eval ("runscope") + "\ n \ t" %>' in the template column'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.