•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,421 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,623 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1549 | Replies: 13
![]() |
•
•
Join Date: May 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
Ok no problem, there is always second way.
Actually the code i sent u<ItemTemplate><asp:Image ID="Image1" ImageUrl='<%# "../UploadedFiles/TemplateImage/" + (Container.DataItem).upload_image_name%>' runat="server"/></ItemTemplate>this was for the particular path : "../UploadedFiles/TemplateImage/" .
U should have to change this path to your own image path where u have stored the image.
If u r working in Product.aspx say and the image is in images folder then the code will be
ImageUrl='<%# "images/" + (Container.DataItem).upload_image_name%>'If it is in a image folder in the parent directory then u have to put a ".." (dot dot) likeImageUrl='<%# "../images/" + (Container.DataItem).upload_image_name%>'If its in the current folder then just leave it blank :ImageUrl='<%# Container.DataItem).upload_image_name%>'I just sended u a example path, u have to change it as urs.
Another thing replace(Container.DataItem).upload_image_namewithEval("upload_image_name").
Or u can do 1 thing , send me the files hierarchy in ur project , i will give u the Imageurl to use , OK .
Thanks, I've tried the code and it is returning an error:
Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'ItemTemplate' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.
Source Error:
<asp:BoundField DataField="ImageName" HeaderText="ImageName" SortExpression="ImageName" />
<asp:BoundField DataField="ProductID" HeaderText="ProductID" SortExpression="ProductID" />
<ItemTemplate>
<asp:Image ID = "Image1" ImageUrl= ImageUrl='<%# "../Images/" + (Container.DataItem).upload_image_name%>' runat="server" />
</ItemTemplate>It is not accepting the <Item Template>.
Is there any other way I can create a store front without using the DataGridview control ie. Datalist or any other methods.
My Images folder is in the root directory as well as the Database Folder (Ms Access) which consist of an Images table containing all the uploaded images.
Thanks
Last edited by peter_budo : May 31st, 2008 at 7:18 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: May 2008
Posts: 34
Reputation:
Rep Power: 1
Solved Threads: 1
Ok no problem, lets get back to the original version. replace the Itemtemplate with the ImageField and put it as before. This time add a FormatString to add the absolute field.
Remember replace the DataImageUrlField value "ImageFileName" to ur own database column name where u have stored the Image file name.Ok. And Change the DataImageUrlFormatString value as per ur folder structure.
Or still further , send me the aspx and code behind files, i would try further.
<asp:ImageField DataImageUrlField="ImageFileName" DataImageUrlFormatString="~/Images/{0}"
Remember replace the DataImageUrlField value "ImageFileName" to ur own database column name where u have stored the Image file name.Ok. And Change the DataImageUrlFormatString value as per ur folder structure.
Or still further , send me the aspx and code behind files, i would try further.
Last edited by sebastian3 : May 31st, 2008 at 2:18 am.
•
•
Join Date: May 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
Ok no problem, lets get back to the original version. replace the Itemtemplate with the ImageField and put it as before. This time add a FormatString to add the absolute field.
<asp:ImageField DataImageUrlField="ImageFileName" DataImageUrlFormatString="~/Images/{0}"
Remember replace the DataImageUrlField value "ImageFileName" to ur own database column name where u have stored the Image file name.Ok. And Change the DataImageUrlFormatString value as per ur folder structure.
Or still further , send me the aspx and code behind files, i would try further.
Hi
I think I've got to the point that I have no more hair left in my head. Still no images loading into the GridView control.
Could you please look at my code maybe there's something that I am missing.
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Index.aspx.vb" Inherits="Index" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/database/myDatabase.mdb"
SelectCommand="SELECT [ProductID], [Product_Name], [Product_Price], [Product_Description], [ImagePath], [ImageName] FROM [Products]">
</asp:AccessDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ProductID" DataSourceID="AccessDataSource1"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="Product_Name" HeaderText="Product_Name" SortExpression="Product_Name" />
<asp:BoundField DataField="Product_Price" HeaderText="Product_Price" SortExpression="Product_Price" />
<asp:BoundField DataField="Product_Description" HeaderText="Product_Description"
SortExpression="Product_Description" />
<asp:BoundField DataField="ImagePath" HeaderText="ImagePath" SortExpression="ImagePath" />
<asp:BoundField DataField="ImageName" HeaderText="ImageName" SortExpression="ImageName" />
<asp:ImageField DataImageUrlField="ImageName" DataImageUrlFormatString="~/Images/{0}">
</asp:ImageField>
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</asp:Content>
The code behind:
Partial Class Index
Inherits System.Web.UI.Page
End ClassI hope this makes sense.
Thanks
•
•
Join Date: May 2008
Posts: 34
Reputation:
Rep Power: 1
Solved Threads: 1
Sorry for replying late,it was a holiday here.
Ok n problem,there is always a solution, just u say what u r storing in ImagePath column of your table. I mean in which format. Whether it is in "/images/folderx/" this format or storing only the folder name like "folderx" or total path "/images/folderx/filex.jpg". These is essential as for the path and the ImageName column so that these can be concatenated to get the original path in correct format. I think u have to bind it in the back end server side code.
Dont panic its not a very big problem, ASP.NET is not that bad at all.
Also please clearly denote the output ur getting, that is the error. Cheer Up Dear
Ok n problem,there is always a solution, just u say what u r storing in ImagePath column of your table. I mean in which format. Whether it is in "/images/folderx/" this format or storing only the folder name like "folderx" or total path "/images/folderx/filex.jpg". These is essential as for the path and the ImageName column so that these can be concatenated to get the original path in correct format. I think u have to bind it in the back end server side code.
Dont panic its not a very big problem, ASP.NET is not that bad at all.
Also please clearly denote the output ur getting, that is the error. Cheer Up Dear
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- How to print from datagrid view ? (VB.NET)
- check box in datagrid view (VB.NET)
- how to print data from datagrid view ? (VB.NET)
- Datagrid view using parameters(Plz help) (VB.NET)
- using summation and aggregate expressions on datagrid/view (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: The message could not be sent to the SMTP server. The transport error code was 0x800c
- Next Thread: how to Read a page in aspx page


Linear Mode