Adding ImageButton into Datalist

G

Guest

Am trying to add an Image Button into a Datalist at Design time.

When I run it it comes up with error: Server tag not well formed.

It works perfectly when I add just an Image Control. Please help.

<asp:DataList
id="dlstframes"
runat="server">
<ItemTemplate>
<asp:ImageButton runat="server"
ImageUrl="<%# Container.DataItem("pictues") %>" />
</ItemTemplate>
</aspataList>

Please do help. I have serched thru the net to find something to solve this
problem. But cant find any clue.
 
G

Guest

You probably have figured out by now that you have typo in the syntax. You
needed to use single quotes to enclose the data binding expression because
the latter contains double quotation marks.

<asp:ImageButton runat="server"
ImageUrl='<%# Container.DataItem("pictues") %>' />
 
G

Guest

I also missed correcting the syntax for databinding which should have been:
<asp:ImageButton runat="server" ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "picturename") %>' />
 
G

Guest

I have tried changing the " to ' and have used DataBinder .Eval and now it
comes up with the error message

Control 'dlstProducts__ctl0__ctl0' of type 'ImageButton' must be placed
inside a form tag with runat=server.

But when I close the <asp:ImageButton with </asp:ImageButton> it still comes
up with error

Server tag not well formed.

Is this a problem with my compiler or something. It works perfectly with the
ordinary image control but not with the ImageButton control.

I really want to know what the problem is comeone help.
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top