how can i display images from localdrive

Posted by Chanti444 under ASP.NET on 10/14/2011 | Points: 10 | Views : 1119 | Status : [Member] | Replies : 8
hi................pls help me its very urgent my abt my requirement

how can i display images from folder i wrote so many ways but here not getting images psl help me asap

satya


Responses

Posted by: Jasc on: 10/14/2011 [Member] Starter | Points: 25

Up
0
Down
Hello Satya, You can use Relative path from you image control Ex: <asp: Image imageurl="~/images/clouds.jpeg" runat="server" id="img1"> Or if you have some other requirement then define.
Jaspal

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

Posted by: Gausi on: 10/14/2011 [Member] Starter | Points: 25

Up
0
Down
hi satya ,

provide your code so that we can try it on our side for better result.

Regards,

Gaurav Singh
(gausi)

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

Posted by: Chanti444 on: 10/14/2011 [Member] Starter | Points: 25

Up
0
Down
k i wil send my code

satya

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

Posted by: Chanti444 on: 10/14/2011 [Member] Starter | Points: 25

Up
0
Down

SqlCommand mycommand = new SqlCommand("GETGALLERYIMAGE", con);
SqlDataAdapter myda = new SqlDataAdapter();
DataSet myds = new DataSet();

mycommand.CommandType = CommandType.StoredProcedure;
con.Open();
myda.SelectCommand = mycommand;
myda.Fill(myds, "galleryimage");

GridView1.DataSource = myds;
GridView1.DataBind();
con.Close();
**********************************************
here gallery image is table name and getgalleryimage is stored procedure name


satya

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

Posted by: Chanti444 on: 10/14/2011 [Member] Starter | Points: 25

Up
0
Down
gallery image contain field image path like below

D:\gallery\2015\jun\13\08-00\birds\birds\1236042179XOjViw.jpg
D:\gallery\2015\jun\13\08-00\birds\birds\birds-flying-764101.jpg
D:\gallery\2015\jun\13\08-00\birds\birds\birds.png
D:\gallery\2015\jun\13\08-00\birds\birds\common_buzzard_AEA251.JPG
D:\gallery\2015\jun\13\08-00\birds\birds\elegant22.jpg
D:\gallery\2015\jun\13\08-00\birds\birds\flying_birds-1234-937016.jpeg
D:\gallery\2015\jun\13\08-00\birds\birds\flying_birds.jpg
D:\gallery\2015\jun\13\08-00\birds\birds\images.jpg
***********************************************************************************
storedprocedure code is

CREATE PROCEDURE GETGALLERYIMAGE
AS
SELECT IMAGEPATH FROM GALLERYIMAGE



satya

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

Posted by: Jasc on: 10/21/2011 [Member] Starter | Points: 25

Up
0
Down
Hello satya in Your gird View where you are binding the dataset. There create Item template and then include image contro to show the images, Ex:
<asp:GridView ID="GridView2" runat="server" CssClass="tableView" autogeneratecolumns="false" gridlines="None"
CellSpacing="0" cellpadding="10" DataKeyNames="OrderID" Width="750px">
<Columns>

<asp:boundfield datafield="OrderID" readonly="true" headertext="No"/>

<asp:TemplateField HeaderText="Status" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Image ID="completedImage" runat="server" ImageUrl="<% # imagepath %>" AlternateText=""/>
</ItemTemplate>
</asp:TemplateField>

</Columns>

</asp:GridView>

Note: That Path like this :D:\gallery\2015\jun\13\08-00\birds\birds\1236042179XOjViw.jpg
as you written in your example would not help you to images. Store the image like this:
1. ~/Images/Animal.jpeg
or
2. http://YousiteName.com/Images/Animal.jpeg

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

Posted by: perfectchourasia-9163 on: 11/15/2011 [Member] Starter | Points: 25

Up
0
Down
THE PATH R U GIVING SHOULD BE IN THE IN THE FOLDER WHERE THE OTHER FILES ARE.

C:\inetpub\wwwroot\WEBSITE\

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

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

Posted by: Vforvijay on: 11/16/2011 [Member] Starter | Points: 25

Up
0
Down
hi...Refer the below articles.....
http://www.dotnetcode.in/StoreImageURLinDatabaseandViewtheimagethroughgridviewusingASP.Net

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

Login to post response