MailTo Link in GridView

G

Guest

How do you create a MailTo Link using the GridView Control with a boundfield
element:
<asp:BoundField HeaderText="Doc Group" DataField="strSubmitter" />

For example, I can use the following in the repeater control:
<a href="mailto:<%#Eval("strOwnerEmail")%>"><%#Eval("strSubmitter")%></a>
 
S

Steven Cheng[MSFT]

Hi Sck10,

As for the problem you mentioned, here are some of my suggestions:

the GridView control infact is very similiar to the DataGrid control in the
current asp.net version which helps to
generate data display pages. And the BoundField in GridView is just the
same as the BoundColumn in the Datagrid , they are mainly focus on display
text datas on the page rather than other customized style. If we want to
build cutsomized style column(field), I suggest that we try the "template
field"(template column in datagrid),
For example:

<columnfields>
<asp:templatefield headertext="OrderID">
<itemtemplate>
<a href='<%# DataBinder.Eval(Container,
"DataItem.LinkUrl") %>'>
</asp:label>
</itemtemplate>
</asp:templatefield>

In addition, I think you can also try using the Datagrid / repeater
controls in asp.net1.1 so as to be more familiar with the asp.net Template
DAtaBound controls. That'll be more helpful.
If you have any other questions, please also feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Steven Cheng[MSFT]

Hi Sck10,

Have you had a chance to check the suggestions in my last reply or have you
got any further ideas? If there're any thing else we can help, please feel
free to post here.Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

I try the following code:
<asp:TemplateField headertext="Email">
<ItemTemplate>
<a href='<%#DataBinder.Eval(Container,
"DataItem.EmailAddress")%>' >
</ItemTemplate>
</asp:TemplateField>
but I want to get the email address from the database. I was not able to
display the email address in the gridview. Please let me know what is wrong
 
Joined
Oct 18, 2007
Messages
2
Reaction score
0
getting email from database

Job_email is pulled from a SQL query from a DB (2.0) with a subject which you can change or remove.

<asp:TemplateField HeaderText="Email">
<ItemTemplate>
<asp:HyperLink ID="EmailLink" text='<%# Bind("job_email") %>' NavigateUrl='<%# Eval("job_email","mailto:{0}?Subject=Career/Employment Inquiry")%>' runat="server" target="_blank" />
</ItemTemplate>
</asp:TemplateField>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top