Binding Directive "Not WELL FORMED???"

A

Alex Maghen

Hi. In a DataGrid TemplateColumn, I'm trying to insert a data-binding
directive and I'm getting a Parse Error - "The server tag is not well
formed". The TemplateColumn Xml looks like:

<ASP:TemplateColumn
HeaderText="PA"
SortExpression="PersianAudio">
<ItemStyle HorizontalAlign="Left" Width="30px" />
<ItemTemplate>
<asp:Image id="PersianAudioIMG" runat="server"
AlternateText="Persian Audio"
ImageAlign="left"
ImageUrl="<%# Convert.ToInt32(DataBinder.Eval(Container.DataItem,
"ID")) %>" />
</ItemTemplate>
</ASP:TemplateColumn>


The error is in the spot where I insert the <%# ... %>. What am I doing
wrong???

Alex
 
S

Scott M.

Your problem is that you have double quotes inside of other double quotes
here:
ImageUrl="<%# Convert.ToInt32(DataBinder.Eval(Container.DataItem,
"ID")) %>"

Change the line to:
ImageUrl='<%# Convert.ToInt32(DataBinder.Eval(Container.DataItem,
"ID")) %>'

so that the entire databinding expression is in single quotes, not doubles.

-Scott
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top