473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

simple syntax q.

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
Jun 8 '06 #1
2 1446
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

Jun 8 '06 #2
Kevin Spencer wrote:
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.

<snipped>

Wow, thanks for that! ...and I thought it would be simple ;)

cheers,
Chris
Jun 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: martin | last post by:
Hello, I just got the SUN Java IDE. (Netbeans IDE 3.5.1) Very very nice, and I worked myself through the tutorial (about making a colorswitch). Now, When I compile it gives no errors at all. So...
27
by: Brian Sabbey | last post by:
Here is a first draft of a PEP for thunks. Please let me know what you think. If there is a positive response, I will create a real PEP. I made a patch that implements thunks as described here....
2
by: Trimbitas Sorin | last post by:
Hello I have a simple syntax question : What does the following line mean: 1: %checkType; ?? I know that @test="" is an array and $test="" is a simple variable. Thank you With best regards...
9
by: Pete | last post by:
Does anyone have a simple html vbscript or other type of snippet they can share that appends a record to a access database via ADO or DAO? I would like to allow users that don't have Microsoft...
7
by: Michael Peters | last post by:
I need a simple editor to edit the texts in static html pages. Is there a program for that? It should be something very simple, nothing like Dreamweaver. I don't need to edit any tables,...
30
by: Brian Elmegaard | last post by:
Hi, I am struggling to understand how to really appreciate object orientation. I guess these are FAQ's but I have not been able to find the answers. Maybe my problem is that my style and...
15
by: gjoneshtfc | last post by:
Hello, I have a simple problem that I just cannot get my head around! I currently have the following line in my ASP recordset: Recordset1.Source = "SELECT * FROM MainTable ORDER BY Price ASC"...
1
by: Bern McCarty | last post by:
I cannot figure out how to do this. It seems that the only way to introduce the "override" keyword into the mix is to give up on the simple property syntax. It seems that the designers of C++/CLI...
8
by: Bern McCarty | last post by:
I have a simple ref class in its own namespace that needs to coexist with a legacy typedef alias for "unsigned int" in the global namespace that has the identifier as itself. Everything compiles...
6
kenobewan
by: kenobewan | last post by:
Congratulations! You are one of the few who realise that over 80% of errors are simple and easy to fix. It is important to realise this as it can save a lot of time. Time that could be wasted making...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.