puzzle over <%# %> evaluation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Repeater that contains two controls, an Anchor (Not runat=server)
and my own Custom Control (runat=server). Each has an attribute whose value
contains <%# %> expressions. The Anchor gets an evaluated value, while my
custom control gets the raw <%# %> characters.
Is there anyway to get my control's parameter evaluated??
 
It can seem like that if the property of the control etc is not covered
fully by the data-binding expression.That's because essentially anchor etc
with no runat="server" it is anyway literal that is produced, so evaluating
it is no big deal. With custom control it's not dealing with literal but
assigning a value to custom control's property

For example: This won't work

ImageUrl='http://www.server.com/<%#DataBinder.Eval(Container.DataItem,"somefield")%>'

but this does work

ImageUrl='<%#DataBinder.Eval(Container.DataItem,"somefield","http://www.server.com/{0}")%>'

(of course, in v2 DataBinder.Eval is just Eval and Container.DataItem is not
needed into the expression but 100% same idea apply)
 
for databinding to work

1) must be a server control, have runat=server, or created in codebehind
2) the parameter value must start with "<%#" and end with "%>"
3) the Databind method must be called


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top