Hi indradeo,
Refer below sample.
HTML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ItemStyle-CssClass="id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
</Columns>
</asp:GridView>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
$('.id').tooltip({
position: { my: "left center", at: "right center" },
items: "tr",
content: function () {
var imagePath = $(this).closest('tr').attr('title');
if (imagePath !== undefined) {
return "<img src='" + imagePath + "' />";
}
}
});
});
</script>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] {
new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Image", typeof(string)) });
dt.Rows.Add(1, "Desert", "Images/Desert.jpg");
dt.Rows.Add(2, "Hydrangeas", "Images/Hydrangeas.jpg");
dt.Rows.Add(3, "Jellyfish", "Images/Jellyfish.jpg");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.ToolTip = (e.Row.DataItem as DataRowView)["Image"].ToString();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Me.IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn(2) {New DataColumn("Id", GetType(Integer)), New DataColumn("Name", GetType(String)), New DataColumn("Image", GetType(String))})
dt.Rows.Add(1, "Desert", "Images/Desert.jpg")
dt.Rows.Add(2, "Hydrangeas", "Images/Hydrangeas.jpg")
dt.Rows.Add(3, "Jellyfish", "Images/Jellyfish.jpg")
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
Protected Sub OnRowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.ToolTip = (TryCast(e.Row.DataItem, DataRowView))("Image").ToString()
End If
End Sub
Screenshot