Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 13-Aug-19 6:02am
Comments
[no name] 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.

 
Share this answer
 
Comments
NoTime1234 13-Aug-19 13:09pm    
Thanks Vincent Maverick Durano for the reply. I did come across your articles before.
Quote:
the aspx page has only the following code.
ASP.NET
<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.
 
Share this answer
 
Comments
NoTime1234 13-Aug-19 13:05pm    
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900