By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,423 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Datalist - Adding Function to Contol?

P: n/a
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
Jun 1 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Andy" <An**@discussions.microsoft.comwrote in message
news:85**********************************@microsof t.com...
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

Jun 2 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.