Click here to Skip to main content
15,904,415 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in Run mode Gridview as follows

Candidatename Photosofcandidate Candidatesignature

Ashwin Ashwin
Baskar Baskar
Chandar Chandar


I required as when user click the Ashwin (Candidatename) in the above Gridview, i want to display the images of Selected Candidate in the Photosofcandidate column in the Gridview.

for the above one, how can i do in asp.net using C#.


regards,
narasiman P
Posted

You can done a simple code. Just use the templateField in Grid view. In TemplateField view invoke the Image button. If you want image URL pick in Database simple like that imageURL
C#
<![CDATA[<%# Eval("Name of The column where is save Image URL")%>]]>
. after then crate a Image button Click event. Image click event in show details of Image. I hope you can understand what i am say.

jsb
 
Share this answer
 
Please don't repost.

I have already answered you at In Gridview image has to displayed for each faculty[^].
 
Share this answer
 
Try this code..


XML
<%@ 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>



C#
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[^]
 
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