How to show image in gridview?

I am working on a live project in which I have to prepare the admin interface. In this admin interface, a website administrator can manipulate user data and images. The problem is that I cannot show the image because I saved the path to the sample in the database in order to bind the user ID. I can also show data, but I do not know how to show data so that the administrator can make changes to it.

+3
source share
2 answers

To display an image, you probably need to make a directory in which you store your images in a virtual directory in IIS. After that, you can create a URL based on the file name. Example:

C:\UserImages\1234.jpg

UserImages , - :

string baseImgUrl = "http://myServer/UserImages/";
FileInfo fi = //load with the file path C:\UserImages\1234.jpg;
img_myImageControl.ImageURL = baseImgUrl + fi.FileName;

, .

0

- , GridView:

<asp:GridView ID="GridView1" runat="server">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <img src='<%# DataBinder.Eval(Container.DataItem,"ImageAddress") %>' alt='I am a user image' />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

, ( , ).

0

All Articles