Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. I'm using ASP.NET (C#). I have designed a gridview and loaded data from database (SQL Server). That's ok.

Here is advanced requirement:
-> The database contains a field that it cannot be showed while debugging. Because I had wrote:
ASP.NET
<asp:BoundField DataField="course_group" HeaderText="Course group" SortExpression="course_group" HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden" />

In css:
CSS
.hidden
{
display: none;
}

-> Now, I wanna get the value of course_group and set it into gridview row as a "Tooltip". Like this:
HTML
<a href="http://www.w3schools.com" title="I'm a tooltip">Visit W3Schools.com!</a>

I know the way to write a link tooltip, but not for gridview row tooltip.

I think it's difficult, because you might want to many different tooltip text for all gridview rows

Is there anyway to do that?
Can you give me any C# code behind solution (mouseover event) or CSS/Javascript code solution (hover event)?
Posted
Updated 28-Mar-15 18:21pm
v2

1 solution

I don't think you need a extra BoundField for the same. You can attach the tooltip to the row inside the RowDataBound Event. Something like this...
C#
protected void gvTestEscapePress_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        // Here get the data of column course_group and assign it to the tooltip below.
        string course_group = "demo text";
        e.Row.ToolTip = course_group;
    }
}

If this does not work, you can try adding mouseover event like...
C#
e.Row.Attributes.Add("onmouseover",  e.Row.ToolTip = "demo text");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900