image is not visible in grid only am getting a box with text image

Posted by Aaryan under ASP.NET on 3/14/2012 | Points: 10 | Views : 1333 | Status : [Member] | Replies : 6
am using coding using adapter and binding in grid view and attaching fields in grid bt cannot get my image in grid... what i sthe problem..



Am using file upload to save image.. am getting filename.postedfile to get the url and saving.. in db my url s stored as this "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\alienware_m17x.jpg". Am also saving in image folder in my project with server mappath... i cannot view image in grid while retrieving in grid view.. why?



I dnt knw where am facing problem.. pls can u help me..




Responses

Posted by: Sksamantaray on: 3/14/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Aryan,
Can you attach your code here?

Thanks,
Sanjay

Aaryan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 3/14/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

use Image/IImage button field in griedview as template field

if not work then please post your code

Thanks
Rajendra Patel

R D Patel

Aaryan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/14/2012 [Member] Silver | Points: 25

Up
0
Down

Hi Aryan,
As you said save the image file in a subfolder of your project using Server.Mappath.
In database you can keep the filename only.
In aspx's templatefield of gridview put an imagebutton and keep lavel or hidden field( which has to bind filename from database)
Next is , in Gridview RowDatabound function find the label or Hiddenfield control and check the existence of filename.
If it is found the set the image url for Imagebutton .Thats it.

Let me know if you follow anything else.

Thanks,
Sanjay

Aaryan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Ok,
do one thing....
Creare one folder called Image in you application root directory.
Create all images that are in your Database, in this folder using hamdler and name them <your-id>.jpg or as per your choice
and then write below code:


<asp:Image ID="id" runat="server" ImageUrl='<%# "Image\" + Eval("id") + ".jpg" %>' />




Mark this as answer, if it helps you................


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Aaryan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Denny on: 3/15/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Make sure that your image url saved in db is right.
If yes,in template field of grid view add a image tool and give the code in source code as given below in grid view template

<ItemTemplate>
<asp:Image ID="img" runat="server" ImageUrl="<%Eval("Your db image column name")%>"/>
</ItemTemplate>

Regards,
Denny Kurian

Aaryan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj_Chennai on: 3/15/2012 [Member] Starter | Points: 25

Up
0
Down
use image field in gridview
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>

<asp:ImageField DataImageUrlField="image" HeaderText="Product">
<ControlStyle Height="100px" Width="100px" />
</asp:ImageField>
<asp:BoundField DataField="producttype" HeaderText="Product Type" />

</Columns>
</asp:GridView>

raj

Aaryan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response