Click here to Skip to main content
13,798,414 members
Rate this:
Please Sign up or sign in to vote.
Hi all,
I need to load an image to image tag .The image name is stored in a table in database.
The image is located in a subfolder in the project folder.What I need is that , there is a gridview and when the corresponding button against the gridview row is clicked, the image should be loaded into the image tag .
How can I do this.Any help will be really appreciated.

What I have tried:

                                                                <td colspan="2" align="right">
                                                                    <asp:UpdatePanel ID="UpdatePanel7" UpdateMode="Conditional" runat="server">
                                                                             <asp:DataList ID="DataList1" Width="100%"  DataSourceID="SqlDataSource1" DataKeyField="IN005_01" runat="server">

                                                                    <asp:Image ID="Image1" Width="100px" Height="100px" ImageUrl='<%# Bind("mgname", "~/UserCertificates/{0}") %>'  runat="server" />
                                                                          <asp:SqlDataSource ID="SqlDataSource1" runat="server" 

                                                                        ConnectionString="<%$ ConnectionStrings:INSMCPConnectionString %>" 

                                                                        SelectCommand="select imgname FROM img  INNER JOIN imgpr ON imgpr.IN005_01=img.IN005_01 where img.IN005_01=@IN005_01 and IN005_01_07='photo'">


                                                                            <asp:ControlParameter ControlID="grd_UserEdit" Name="IN005_01" 

                                                                                PropertyName="SelectedValue" />


<asp:AsyncPostBackTrigger ControlID="but_search" />
<asp:AsyncPostBackTrigger ControlID="grd_UserEdit" />
Posted 2-Jan-18 1:39am
Updated 2-Jan-18 21:28pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


This has been asked many times before in various forums. I would highly recommend you to do a quick search in the web to get more examples.

Here are some articles that I've blogged about before regarding saving, validating and displaying images in the context of ASP.NET that might be useful for your case: ASP.NET WebForms: Uploading, Validating And Displaying of Image[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.181207.3 | Last Updated 3 Jan 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100