Try this code..
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Gridpage.aspx.cs" Inherits="POC.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-1.10.2.js" type="text/javascript"></script>
<script type="text/javascript">
var showimage = function (thisobject) {
var image = $('img[id*="imgcandidate"]', $(thisobject).parent().parent());
if (image.css('display') == 'block')
image.css('display', 'none');
else
image.css('display', 'block');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%">
<Columns>
<asp:TemplateField HeaderText=" Candidate name">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnCandidatename" runat="server" OnClientClick="showimage(this); return false;"
Text='<%# Bind("Candidatename") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Photo of candidate">
<ItemTemplate>
<asp:Image ID="imgcandidate" ImageUrl='<%# Bind("Photosofcandidate") %>' runat="server" Style="display: none"
Height="100px" Width="100px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Candidatename", typeof(string));
dt.Columns.Add("Photosofcandidate", typeof(string));
dt.Rows.Add("karthik", @"~\images\box.jpg");
dt.Rows.Add("parthip", @"~\images\box.jpg");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
Add jquery reference to it.
http://code.jquery.com/jquery-1.10.2.min.js[
^]