|
-
Aug 8th, 2005, 06:33 AM
#1
Thread Starter
Frenzied Member
displaying pictures in a datagrid. path in DB
Hello,
I am using a ASP.Net application that has to upload pictures and display them in a datagrid. I cannot get the pictures to display. This is what l have done so far, and not sure if l am doing this the right way. I am hopping the one of you experts can tell me how to do it in a professional way.
I want have the path to the pictures in the database. But l am unsure where to place the folder that will have the pictures. The folder is called images.
The path of my application is C:\Condo\CondoInformationSystem
<asp:TemplateColumn>
<ItemTemplate>
<img src='<%# DataBinder.Eval(Container.DataItem, "Picture") %>' />
</ItemTemplate>
</asp:TemplateColumn>
"Picture" is the name of the database field, where the path will be stored.
I think l have to have the images in a virtual path so it could be C:\Inetpub\wwwroot\condo\condoinformationSystem\images
The folder "images" is where the pictures are. Is this what l should have in the database field. Not sure about this, but l read somewhere you should have only the name of the picture in this field. e.g. mypicture1.jpg. My question would be, how will the program know where this picture is?
VB Code:
string fileTarget = "C:\\Inetpub\\wwwroot\\CondoInformationSystem\\image\\";
fileTarget += Path.GetFileName(ctrlFilePath.PostedFile.FileName.ToString());
if (File.Exists(fileTarget))
{
Response.Write("File has already been uploaded");
}
else
{
ctrlFilePath.PostedFile.SaveAs(fileTarget);
}
//With this l can store the path in the database picture field, or just the name of the picture.
What l have done so far, does not work.
Please can you help me solve this problem,
Many thanks in advance,
Steve
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|