473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

'Container.DataItem' is not declared

Hello,

in my aspx.file I have this code inside a datagrid:

<asp:TemplateColumn HeaderText="Picture">
<ItemTemplate>
<asp:Image id="Image1" runat="server" ImageUrl='upload/<%# Container.DataItem("photo")%>'></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>

When I try to execute my page, I dont get any error but the image is not displayed.
Right clicking on web page in Internet Explorer i get this path: "c:\inetpub\wwwroot\website\upload\<%# Container.DataItem("photo")%>"
If i set a breakpoint on asp:image tag, i try to watch Container.DataItem("photo") value but I can read only this message: "'Container.DataItem' is not declared or the module containing it is not loaded in the debugging session."
So, what's wrong?!?

please help
Antony
Dec 26 '05 #1
2 3379
Put it like this in the ItemTemplate

<ItemTemplate>
<asp:Image id="Image1" runat="server" ImageUrl='<%#
DataBinder.Eval(Container.DataItem,"photo","upload/{0}")%>' />
</ItemTemplate>

E.g when binding to a property you need to build it all within the
databinding expression(here with the help of string formatting), otherwise
it all is interpreted as string, and the expression won't be evaluated.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Antony" <th********@libero.it> wrote in message
news:Xn********************************@193.70.192 .192...
Hello,

in my aspx.file I have this code inside a datagrid:

<asp:TemplateColumn HeaderText="Picture">
<ItemTemplate>
<asp:Image id="Image1" runat="server" ImageUrl='upload/<%#
Container.DataItem("photo")%>'></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>

When I try to execute my page, I dont get any error but the image is not
displayed.
Right clicking on web page in Internet Explorer i get this path:
"c:\inetpub\wwwroot\website\upload\<%# Container.DataItem("photo")%>"
If i set a breakpoint on asp:image tag, i try to watch
Container.DataItem("photo") value but I can read only this message:
"'Container.DataItem' is not declared or the module containing it is not
loaded in the debugging session."
So, what's wrong?!?

please help
Antony

Dec 26 '05 #2
many thanks!
You healed my headache! :)

bye
Antony

"Teemu Keiski" <jo****@aspalliance.com> wrote in
news:ec**************@TK2MSFTNGP14.phx.gbl:
Put it like this in the ItemTemplate

<ItemTemplate>
<asp:Image id="Image1" runat="server" ImageUrl='<%#
DataBinder.Eval(Container.DataItem,"photo","upload/{0}")%>' />
</ItemTemplate>

E.g when binding to a property you need to build it all within the
databinding expression(here with the help of string formatting),
otherwise it all is interpreted as string, and the expression won't be
evaluated.


Dec 26 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chumley the Walrus | last post by:
I need to assign a variable to a record drawn from a db by way of a repeater control: <ASP:Repeater id="thedata" runat="server"> <itemtemplate> <%dim display display =...
0
by: Chumley the Walrus | last post by:
Inside a datalist, or repeater control <itemtemplate>, i'm trying to do an If statement with objects from my recordset : <% if (Container.DataItem("mydbfield")) <> "" then...
2
by: az bij | last post by:
Hi, I have a dataset bound to a repeater and want to place some logic in my ascx file. I want to display an image link if and only if an image is available. I have tried without success...
1
by: fig000 | last post by:
Hi, I have some code written into the html in a dot.net form: <%if test(Container.DataItem("user_id")) =2%> I've been able to use container.dataitem in these <%%> pairs as an expression to...
1
by: Mike P | last post by:
I'm having trouble with C# syntax for Container.DataItem. This is the VB version. CAn anybody help me out with the syntax? <asp:DataList runat="server" id="dlResults" Font-Name="Verdana"...
5
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash...
1
by: justengland | last post by:
Ok After spending why to long on this problem I found out that I was infact stupid. the problem was that I needed to add a # sign This is wrong <% DataBinder.Eval(Container.DataItem,...
0
by: John Davis | last post by:
Hi all, hope you are well. I would like to know if I can access the strongly typed properties of my datatable when binding through the ObjectDataSource object. I am currently creating some...
3
by: alberthung01 | last post by:
Hi all, I try to use Container.DataItem() in my DataGrid's ItemTemplate. Somewhere it works fine. eg.<input type=checkbox id='cb_select_<%# Container.DataItem("TAG_ID") %>' value='<%#...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.