User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2008
Posts: 12
Reputation: Techbee is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Techbee Techbee is offline Offline
Newbie Poster

Re: DataGrid View

  #11  
May 30th, 2008
Originally Posted by sebastian3 View Post
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) like ImageUrl='<%# "../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_name with Eval("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
Reply With Quote  
Join Date: May 2008
Posts: 34
Reputation: sebastian3 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
sebastian3 sebastian3 is offline Offline
Light Poster

Re: DataGrid View

  #12  
May 31st, 2008
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.
Last edited by sebastian3 : May 31st, 2008 at 2:18 am.
Reply With Quote  
Join Date: May 2008
Posts: 12
Reputation: Techbee is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Techbee Techbee is offline Offline
Newbie Poster

Re: DataGrid View

  #13  
May 31st, 2008
Originally Posted by sebastian3 View Post
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">
    &nbsp;<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 Class

I hope this makes sense.

Thanks
Reply With Quote  
Join Date: May 2008
Posts: 34
Reputation: sebastian3 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
sebastian3 sebastian3 is offline Offline
Light Poster

Re: DataGrid View

  #14  
Jun 5th, 2008
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 1:55 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC