Show GridView row details in tooltip on mouseover with jQuery using inside GridView in c#

In this blog i am going to explain how to show gridview row details in tooltip on mouseover with jQuery using in C#

  • First of all in the design page(.aspx) write place Gridview as following::

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewToolTipaspx.aspx.cs" Inherits="GridViewToolTipaspx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <script src="" type="text/javascript"></script>
<script src="js/jquery.tooltip.min.js" type="text/javascript"></script>
<script type="text/javascript">
    function InitializeToolTip() {
            track: true,
            delay: 0,
            showURL: false,
            fade: 100,
            bodyHandler: function () {
                return $($(this).next().html());
            showURL: false
<script type="text/javascript">
    $(function () {
<style type="text/css">
#tooltip {
position: absolute;
z-index: 3000;
border: 1px solid #111;
background-color: #FEFFFF;
padding: 5px;
opacity: 0.85;
#tooltip h3, #tooltip div { margin: 0; }
    <form id="form1" runat="server">
<asp:GridView ID="gvDetails" AutoGenerateColumns="false" CellPadding="5" runat="server">
<asp:TemplateField HeaderText="UserId">
<ItemStyle Width="30px" HorizontalAlign="Center" />
<a href="#" class="gridViewToolTip"><%# Eval("UserId")%></a>
<div id="tooltip" style="display: none;">
<td style="white-space: nowrap;"><b>Name:</b>&nbsp;</td>
<td><%# Eval("Name")%></td>
<td style="white-space: nowrap;"><b>Designation:</b>&nbsp;</td>
<td><%# Eval("Designation")%></td>
<td style="white-space: nowrap;"><b>Department:</b>&nbsp;</td>
<td><%# Eval("Department")%></td>
<asp:BoundField HeaderText="UserName" DataField="Name" />
<asp:BoundField HeaderText="Designation" DataField="Designation" />
<asp:BoundField HeaderText="Department" DataField="Department" />
<HeaderStyle BackColor="#CCCCCC" Font-Bold="true" ForeColor="Black" />

  • Now, in the code behind file(.aspx.cs) write the code as ::

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;

public partial class GridViewToolTipaspx : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
    protected void BindGrid()

        DataTable dt = new DataTable();
        dt.Columns.Add("UserId", typeof(Int32));
        dt.Columns.Add("Name", typeof(string));
        dt.Columns.Add("Designation", typeof(string));
        dt.Columns.Add("Department", typeof(string));

        DataRow dr = dt.NewRow();
        dr["UserId"] = 1;
        dr["Name"] = "Aayush";
        dr["Designation"] = "Associate Technical Consultant";
        dr["Department"] = null;

        dr = dt.NewRow();
        dr["UserId"] = 2;
        dr["Name"] = "Anish";
        dr["Designation"] = null;
        dr["Department"] = null;

        dr = dt.NewRow();
        dr["UserId"] = 3;
        dr["Name"] = "Manish";
        dr["Designation"] = null;
        dr["Department"] = "Navision";

        dr = dt.NewRow();
        dr["UserId"] = 4;
        dr["Name"] = "Ravish";
        dr["Designation"] = "Tech Lead";
        dr["Department"] = "CRM";

        for (int i = 0; i < dt.Rows.Count; i++)
            for (int j = 0; j < dt.Columns.Count; j++)
                if (string.IsNullOrEmpty(dt.Rows[i][j].ToString()))
                    dt.Rows[i][j] = "Data Not Available";
        gvDetails.DataSource = dt;

Note: Don't forget to add "jquery.tooltip.min.js" in your solution folder. I have added .js file in js folder(You will get easily on net)

Output will be like this when you mouseover the first column of the gridview ::


  1. Nice post,
    Here i have similar article i.e Gridview row mouse-over show detail data in floating div with jquery , but instead of mouse-over on button, user can mouse-over on each row and data will get display.

  2. I copied this scenario to my project. When I run it in Visual Studio, it works fine but it doesn't show tooltip on the server (tried both IE and Firefox). What could be the problem?

  3. there is another problem... if a tooltip is really large, then it goes up and gets hidden under menu control if someone uses one. Even z-index: 3000; doesn't help


Post a comment

Popular posts from this blog

StateCode and StatusCode Values for mostly used entities in Microsoft Dynamics CRM 2013

How to show enlarge image when mouse hover on image or link in Asp.Net(c#) using JavaScript

How to import CSV files into DataTable in C#

go to top image