How to Show Tooltip for gridview cell on OnMouseOver

Hi,
Here I will code you how to show the tooltip for the gridview cells, each cell of the gridview have their own data, in the below code am going to show the gridview cell data as a tooltip for each cell. Here I am applying the tooltip property in gridviews RowDataBound property.



ASPX CODE:


<html>
<head runat="server">
    <title>fourthbottle</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="grd_popup_details" HeaderStyle-BackColor="#cccccc" runat="server" OnRowDataBound="grd_popup_details_RowDataBound">
        </asp:GridView>
    </div>
    </form>
</body>
</html>

C# CODE

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

namespace TTip
{
   public partial class tt : System.Web.UI.Page
   {
      protected void Page_Load(object sender, EventArgs e)
      {
         SqlConnection con = new SqlConnection("your connection string");
          string Query = "sql query";
          SqlDataAdapter da = new SqlDataAdapter(Query, con);
          DataSet DS = new DataSet();
              con.Open();
              da.Fill(DS);
              grd_popup_details.DataSource = DS;
              grd_popup_details.DataBind();
              con.Close();
      }

    protected void grd_popup_details_RowDataBound(object sender, GridViewRowEventArgs e)
     {
         for (int i = 0; i < e.Row.Cells.Count; i++)
         {
            e.Row.Cells[i].ToolTip = e.Row.Cells[i].Text;
         }
     }
   }
}