Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Plz help me .. i am trying to show the pic in grid view but my code is not working....
Posted
Comments
preet88 27-Jun-12 12:07pm    
hi asim please make it clear from where you are getting the data or url of pic.

 
Share this answer
 
Comments
Espen Harlinn 27-Jun-12 19:12pm    
Really nice links :-D
Sandeep Mewara 28-Jun-12 9:01am    
Thanks Espen.
hi asim
im assuming that you have it in your database
XML
<asp:GridView ID="GridView1" runat="server">
          <Columns>
              <asp:TemplateField>
                  <ItemTemplate>
                      <asp:Image ID="Image1" ImageUrl="bind the column name from database here" runat="server" />
                  </ItemTemplate>
              </asp:TemplateField>
          </Columns>
      </asp:GridView>


for other columns you can repeat this template field.
hope it will help
thanks
 
Share this answer
 
v2
Comments
Asim8748 27-Jun-12 12:20pm    
Hi Preet !

I am also using this code but it shows the other coloumns same as i input but does not show the image in grid ...
preet88 28-Jun-12 5:20am    
hi then you must be storing image data instead of url of image... for now i suppose you may to take asp:imagefield as suggested in solution 2 but i'm not sure if it works with data..
im able to find some links hopefully they may help you
http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspx
http://www.dotnetfunda.com/articles/article1084-saving-images-into-the-database-in-aspnet-and-displaying-to-the-gridview-.aspx
For future i suggest you that store relative path instead of image data as image data degrades your query performance..
thanks.
instead of using asp:image in ItemTemplae use below code
<asp:imagefield dataimageurlfield="ImageURLfromdatarow"/>
 
Share this answer
 
v2

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