473,395 Members | 1,936 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,395 software developers and data experts.

Mailto link with data from SQLDataSource

Hi,

I want to create a mailto link from data coming from an SQLDataSource. How
do I have to change the following code to get it working? The mailto works,
outlook starts with a new message, but the email address has not been filled
in because I don’t know how to pass the email variable into the mailto
command.

<asp:HyperLink runat="server">
<A href="mailto:">
<asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email")
%>'></asp:Label><br />
</asp:Hyperlink>
</A>

Thanks in advance,
Regards,
Peter

Feb 7 '07 #1
2 6292
Peter,

The Bind() and Eval() functions take an optional format string that can be
used to format the data that is bound to a target property. In your case you
can format the NavigateUrl on a Hyperlink control to be something like
"mailto:ya**@xyz.com". Change your Bind(..) or Eval(..) call to
Bind("Email", "mailto:{0}"). The token {0} in the format string is replaced
the value of "Email" from your SqlDataSource.

Also, binding to SqlDataSource only works with server controls that support
Data Binding (Server controls that have a DataSourceID, such as the GridView,
FormView, DetailsView, DropDownList, CheckBoxList, BulletedList, etc.).

Here is an example of a GridView that has a bound mailto column using a
Hyperlink control.

Hope this helps,
Jason Vermillion

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Binding Using a format string">
<ItemTemplate>
<asp:HyperLink ID="lnkEmail" runat="server" NavigateUrl='<%#
Eval("Email", "mailto:{0}") %>' Text='<%# Eval("Email", "Send an Email to
{0}") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Hi,

I want to create a mailto link from data coming from an SQLDataSource. How
do I have to change the following code to get it working? The mailto works,
outlook starts with a new message, but the email address has not been filled
in because I don’t know how to pass the email variable into the mailto
command.

<asp:HyperLink runat="server">
<A href="mailto:">
<asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email")
%>'></asp:Label><br />
</asp:Hyperlink>
</A>

Thanks in advance,
Regards,
Peter
Feb 8 '07 #2
Thanks a lot Jason. It works.
Regards,
Peter

"Jason Vermillion" wrote:
Peter,

The Bind() and Eval() functions take an optional format string that can be
used to format the data that is bound to a target property. In your case you
can format the NavigateUrl on a Hyperlink control to be something like
"mailto:ya**@xyz.com". Change your Bind(..) or Eval(..) call to
Bind("Email", "mailto:{0}"). The token {0} in the format string is replaced
the value of "Email" from your SqlDataSource.

Also, binding to SqlDataSource only works with server controls that support
Data Binding (Server controls that have a DataSourceID, such as the GridView,
FormView, DetailsView, DropDownList, CheckBoxList, BulletedList, etc.).

Here is an example of a GridView that has a bound mailto column using a
Hyperlink control.

Hope this helps,
Jason Vermillion

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Binding Using a format string">
<ItemTemplate>
<asp:HyperLink ID="lnkEmail" runat="server" NavigateUrl='<%#
Eval("Email", "mailto:{0}") %>' Text='<%# Eval("Email", "Send an Email to
{0}") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Hi,

I want to create a mailto link from data coming from an SQLDataSource. How
do I have to change the following code to get it working? The mailto works,
outlook starts with a new message, but the email address has not been filled
in because I don’t know how to pass the email variable into the mailto
command.

<asp:HyperLink runat="server">
<A href="mailto:">
<asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email")
%>'></asp:Label><br />
</asp:Hyperlink>
</A>

Thanks in advance,
Regards,
Peter
Feb 8 '07 #3

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

Similar topics

12
by: ElvisIsDead | last post by:
Have a script that takes a form and emails it automatically. Here is the part: <form onSubmit="return editData();" name="estm" enctype="text/plain" method="post"...
18
by: Shinin | last post by:
I am trying to set up a mailto: link so that the actual address that the email is being sent to is obscured and replaced by a name. For example, I have <a href="mailto:jschmoe@abc.com">Joe...
3
by: Brian Bischof | last post by:
I'm have a form with a datagrid showing a checkbox for each row. I want the user to be able to click a checkbox and then click a button that sends an email similar to how the HREF MailTo: works. I...
9
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
4
by: trichert | last post by:
Ok , developing a .aspx page with Visual Web Studio (the full page is at the bottom). Basically its a page that displays all my computers and the current logged on user pulling data from a live...
3
by: RAR in WA | last post by:
I'm moving to .Net framework 2.0 from Visual Studio 2002/3 with more time on desktop apps than ASP.Net, although I have done a small amount in ASP.Net. Is best practice for ASP.Net now to use the...
6
by: Ken Fine | last post by:
I'm using SQLDataSource, which generates some kind of dataset, and then I attach that datasource to various data display controls such as DataList and repeater which loop through to the end of the...
1
by: Corey B | last post by:
I have a page with a DetailsView control and a SQLDataSource control. The SQLDataSource control is connected to an Access database. Everything works fine. Now I want to change the back end...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.