Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

The name 'Container' does not exist in the current context

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Morris - 17 Mar 2008 17:27 GMT
I have an ASP:Repeater which shows Title, DateCreated, State

In addition I want two extra columns in my table

01: Modify (this works)
02: Publish or Withdraw depending on Item.CanPublish or Item.CanWithdraw

  <tr class="DataListStyle">
   <td><%# Html.Encode((string)DataBinder.Eval(Container.DataItem,
"Title")) %></td>
   <td><%# DataBinder.Eval(Container.DataItem, "DateCreated") %></td>
   <td><%# DataBinder.Eval(Container.DataItem, "State") %></td>
   <td><a href="/Advert/Modify/<%# Eval("ID") %>">Modify</a></td>
   <td>
    <% if ((bool)DataBinder.Eval(Container.DataItem, "CanPublish")) { %>
     <a href="/Advert/Publish/<%# Eval("ID") %>">Publish</a>
    <% } %>
    <% if ((bool)DataBinder.Eval(Container.DataItem, "CanWithdraw")) { %>
     <a href="/Advert/Withdraw/<%# Eval("ID") %>">Witdraw</a>
    <% } %>
   </td>
  </tr>

ERROR: CS0103: The name 'Container' does not exist in the current context

If instead I use the following

<% if ((bool)Eval("CanPublish")) { %>

I get the error

ERROR: Databinding methods such as Eval(), XPath(), and Bind() can only be
used in the context of a databound control.

So, how do I achieve this?

Thanks

Pete
bruce barker - 17 Mar 2008 17:51 GMT
you are confusing databinding expressions (<%# %>) which must be an
expression, becuase it generates the code:
 
  value = expression

with serverside code blocks (<% %>) which must be statements. code blocks do
not have a binding context.

-- bruce (sqlwork.com)

> I have an ASP:Repeater which shows Title, DateCreated, State
>
[quoted text clipped - 35 lines]
>
> Pete
Peter Morris - 17 Mar 2008 18:57 GMT
> with serverside code blocks (<% %>) which must be statements. code blocks
> do
> not have a binding context.

So how do I get the property value of the current object being databound?  I
need to know if CurrentItem.CanPublish.  Surely this is not impossible?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.