Datalist - Adding Function to Contol?

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

Guest

Hello All:

I have the following DataList. In the <TD class="photo"> line, I would like
to be able to add some code where I can gather the actual size of the photo,
then pass that to the popImage javascript function. I am really at a loss at
this time as to how to do this. Could anyone give me some direction on how I
can go about doing this/

<asp:DataList
ID="photos"
RepeatColumns="5"
RepeatDirection="Horizontal"
CellPadding="10"
EnableViewState="false"
Runat="server">
<ItemTemplate>
<table width="100%">
<tr>
<td valign="top">
<table class="rightSideTable" width="100%">
<tr>
<td valign="top" class="rightSideTitle">
<%# DataBinder.Eval(Container.DataItem, "Title") %>
</td>
</tr>
<tr>
<td class="photo">
<a href="javascript: popImage('/Photos/Photos/<%#
DataBinder.Eval
(Container.DataItem, "Path") %>',
'<%# DataBinder.Eval(Container.DataItem, "Title")
%>')">
<img src="/Photos/Thumbnails/<%#
DataBinder.Eval(Container.DataItem, "Thumbnail") %>"
width="133" height="100" border="0" alt="">



</a>
</td>
</tr>
<tr>
<td class="rightSideInfo"><%#
DataBinder.Eval(Container.DataItem, "Location") %></td>
</tr>
<tr>
<td class="rightSideInfo"><%#
DataBinder.Eval(Container.DataItem, "ImageDate") %></td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

Thanks
Andy
 
You may want to look into using the ItemDataBound event. While in the
ItemDataBound event, you can access controls that are part of the Item by
using the following method:

CType(e.Item.FindControl("btnMoveUp"), Button)

You would then treat the above code exactly the same as if it were the
control (you can access/set properties, use methods, etc.) Good Luck!
 
Back
Top