Create a method to which you can pass the email string and which will
concatenate the string with the "mailto" portion of the URL. In your
template, call this method, rather than using the DataBinder.Eval method. To
do this, you use a DataBinding Expression that references
"Container.DataItem" - this is a reference to the DataSource that is bound
to the template. It is necessary to cast this to the actual type of the
DataSource, whatever that may be.
Here's an example in which a Repeater is DataBound to a DataTable. It calls
a number of custom methods, referencing various elements in the DataTable,
including the DataTable itself, to customize the data contained in the
DataTable:
<table class="distributionResults" cellspacing="0">
<asp:repeater id="Repeater1" runat="server">
<ItemTemplate>
<tr>
<th colspan="2">
<%# EvalTableName(((DataTable)Container.DataItem).Tabl eName, 1) %>
</th>
<th colspan="3" style="text-align: right;">
<%# EvalTableName(((DataTable)Container.DataItem).Tabl eName, 2) %>
</th>
</tr>
<tr>
<td><strong>ICAO</strong></td>
<td><strong>Latest METAR Processed</strong></td>
<td><strong>Latest Found on Site</strong></td>
<td><strong>Timestamp Difference</strong></td>
<td><strong>Report Time Difference</strong></td>
</tr>
<asp:Repeater id='Repeater2' runat='server' DataSource='<%#
DataBinder.Eval((DataTable)Container.DataItem, "Rows") %>'>
<ItemTemplate>
<tr style='<%#
EvalTimeSpan(((DataRow)Container.DataItem)["Difference"]) %>'>
<td nowrap><%# ((DataRow)Container.DataItem)["Icao"] %></td>
<td nowrap><%#
EvalDateTime(((DataRow)Container.DataItem)["LatestProcessed"],
((DataRow)Container.DataItem)["Difference"]) %></td>
<td nowrap><%#
EvalDateTime(((DataRow)Container.DataItem)["LatestFound"]) %></td>
<td nowrap><%#
TimeSpanValue(((DataRow)Container.DataItem)["Difference"]) %></td>
<td nowrap><%#
TimeSpanValue(((DataRow)Container.DataItem)["ReportTimeDifference"]) %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:repeater>
</table>
The methods EvalTableName, EvalTimeSpan, EvalDateTime, and TimeSpanValue are
all custom methods that I created to format the data displayed.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist
A lifetime is made up of
Lots of short moments.
"Not Me" <no****@abc.blah.org> wrote in message
news:e6**********@ucsnew1.ncl.ac.uk...
Hi,
Yet another error that should be easy to fix.. I have a datalist linked to
an sqldatasource, and I'm wanting to fill it with data from that source.
The following works fine:
<ItemTemplate>
<asp:hyperlink runat="server" ID="hlemail" Text='<%# eval("[email]") %>'
navigateurl='<%# eval("[email]") %>'/>
</ItemTemplate>
But, for the navigateurl I don't just want it to show the email address as
a standard link, I want the full mailto: link. I've tried the following
to no avail
'mailto:' + <%# eval...
"mailto:" + <%# eval...
'mailto:' & <%# eval...
"mailto:" & <%# eval...
they all give compilation errors
mailto:<%# eval("[preferred email address]") %> also gives an error..
'mailto:<%# eval("[preferred email address]") %>' (with 's) just includes
the whole eval statement in the output...
any clues? I seem to be going round in circles at the minute!
cheers,
Chris