ImageButton server control in a Datalist Prob.

J

John Stemper

I've got a problem getting a data element in a Databound datalist to tie in
with an Imagebutton control in the ItemTemplate of the Datalist control.
I've attached the code below. The second dataelement (Name) works fine but
the first one (ImageFileName) doesn't work.
Anyone have any ideas?
TIA
John


<asp:datalist id="dlDesigns" runat="server" HorizontalAlign="Center"
ShowFooter="False" RepeatColumns="3" RepeatDirection="Horizontal"
ShowHeader="False">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:ImageButton id="imBtn" runat="server" OnClick="dlSelectEvent"
ImageUrl="/images/<%# DataBinder.Eval(Container,'DataItem.ImageFileName')%">
</asp:ImageButton>
<BR>
Name: <%#DataBinder.Eval(Container, "DataItem.Name") %>
</ItemTemplate>
</asp:datalist>
 
J

John Stemper

I just wanted to clarify.. The image path and filename is what I'm trying to
get to appear.

John
 
D

Duray AKAR

ImageUrl is a server side Property, while the other
item is being written on page prerender, namely after the
code is executed...

That is the difference between those two...


try
ImageUrl='<%# "/images/" + DataBinder.Eval
(Container,"DataItem.ImageFileName").ToString()%>'

it will work i guess..

Hope it helps..

Duray AKAR
 
Y

Yan-Hong Huang[MSFT]

Hello John,

I think the problem exists in the value of ImageURL. You could print our
this string to see if it is correct. At least, you need to put "/images/"
into the <% %> block. Thanks.

Best regards,
yhhuang
VS.NET, Visual C++
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
!Content-Class: urn:content-classes:message
!From: "Duray AKAR" <[email protected]>
!Sender: "Duray AKAR" <[email protected]>
!References: <[email protected]>
!Subject: ImageButton server control in a Datalist Prob.
!Date: Thu, 3 Jul 2003 10:04:25 -0700
!Lines: 51
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNBhSfohzd7uPzJS4SEHTtcQHJy6g==
!Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
!Path: cpmsftngxa09.phx.gbl
!Xref: cpmsftngxa09.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:3235
!NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
!
!ImageUrl is a server side Property, while the other
!item is being written on page prerender, namely after the
!code is executed...
!
!That is the difference between those two...
!
!
!try
!ImageUrl='<%# "/images/" + DataBinder.Eval
!(Container,"DataItem.ImageFileName").ToString()%>'
!
!it will work i guess..
!
!Hope it helps..
!
!Duray AKAR
!
!>-----Original Message-----
!>I've got a problem getting a data element in a Databound
!datalist to tie in
!>with an Imagebutton control in the ItemTemplate of the
!Datalist control.
!>I've attached the code below. The second dataelement
!(Name) works fine but
!>the first one (ImageFileName) doesn't work.
!>Anyone have any ideas?
!>TIA
!>John
!>
!>
!><asp:datalist id="dlDesigns" runat="server"
!HorizontalAlign="Center"
!>ShowFooter="False" RepeatColumns="3"
!RepeatDirection="Horizontal"
!>ShowHeader="False">
!><ItemStyle HorizontalAlign="Center"></ItemStyle>
!> <ItemTemplate>
!> <asp:ImageButton id="imBtn" runat="server"
!OnClick="dlSelectEvent"
!>ImageUrl="/images/<%# DataBinder.Eval
!(Container,'DataItem.ImageFileName')%">
!> </asp:ImageButton>
!> <BR>
!> Name: <%#DataBinder.Eval(Container, "DataItem.Name") %
!>
!> </ItemTemplate>
!></asp:datalist>
!>
!>
!>.
!>
!
 

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,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top