Click here to Skip to main content
14,265,815 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a gridview which i am populating using a stored procedure in the code behind.
the aspx page has only the following code.
<pre> <asp:GridView ID="GridView2" runat="server"  CssClass="GridStyle"   >
        </asp:GridView>

1 of the fields returned by sp is the location for images.the images are stored in the image folder in the project folder. So depending on the conditions the path is returned something like
'/Images/Evs/BB'
.
But the image is not appearing ,it just shows as the location as retrieved.
I do not know what is the issue and what should i do? Thanks in advance.

What I have tried:

i tried using the same image in a simple div and the image appears. please suggest .
Posted
Updated 4 days ago
Comments
Gerry Schmitz 10-Aug-19 15:10pm
   
Try showing WITHOUT the grid. If that works, then worry about the grid.
NoTime1234 10-Aug-19 15:16pm
   
Thanks for the reply. I have already tried it outside the grid to test the path and it works alright(mentioned under "what i have tried"). what do you suggest?TIA.
Mohibur Rashid 10-Aug-19 23:52pm
   
Go to debug window. Check if any 404 error. Go to source and check if the image path okay or not.
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Comments
NoTime1234 4 days ago
   
Thanks Vincent Maverick Durano for the reply. I did come across your articles before.
Rate this:
Please Sign up or sign in to vote.

Solution 2

Quote:
the aspx page has only the following code.
<asp:GridView ID="GridView2" runat="server" CssClass="GridStyle">
</asp:GridView>

You're relying on auto-generated columns. The problem is, there is no way for the grid to know whether the string returned from the database needs to be displayed as a string, an image, a hyperlink, or something else entirely.

You need to make the column an ImageField, or a TemplateField containing an Image control. The simplest way to do that is to set the AutoGenerateColumns property[^] to false and manually create the columns you want to display.

Otherwise, you'd need to create a custom GridViewColumnsGenerator[^] class and set the grid's GridView.ColumnsGenerator property[^] to an instance of that class.
   
Comments
NoTime1234 4 days ago
   
Even though i did not use your solution , I realized the issue some time back and changed the code to create the columns, setting AutoGenerateColumns property to false .I have used a template column with asp:hyperlink where i gave the imageurl as path to the images which is from stored procedure using Eval. Thanks for the reply.

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




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