datagrids and email addresses

  • Thread starter Thread starter kieran
  • Start date Start date
K

kieran

Hi,

i know this should be easy but cant get it exactly right.

i have a Datagrid pulling results from a stored proc in database, it
outputs four columns, one of which is an email address column. i am
trying to get all the email addresses to be clickable email links
using the mailto: scenerio but am having trouble with code as im a
newbie.

i have looked for examples but nothing quite fits. As you can see from
code i have been messing with 'ds.Tables(0).Columns'. Is this the best
way to do it? Where am i going wrong?

All help very much appreciated.



Dim daPhone As New SqlClient.SqlDataAdapter
daPhone.SelectCommand = New SqlClient.SqlCommand
daPhone.SelectCommand.Connection = con
daPhone.SelectCommand.CommandText =
"TEST_OUTPUT_FIRSTNAME"
daPhone.SelectCommand.CommandType =
CommandType.StoredProcedure
daPhone.SelectCommand.Parameters.Add(workParam)

Dim ds As DataSet
ds = New DataSet
daPhone.Fill(ds, "tblPhone")

Dim col As DataColumn
For Each col In ds.Tables(0).Columns("email")
lstItems.Items.Add(col.ColumnName)
Next

dgPhone.DataSource = ds
dgPhone().DataBind()
 
Hi Ken,

Cheers for reply. i was messing with code to try and see the column
names so the list of items doesnt matter, i should have removed it
from the code. what im trying to do is get the email addresses to be
written as email links. each of the email addresses are in a column
named 'email'.
im sure it should just be a while statement that appends the mailto
part to each entry in the column 'email' but can not get it at all.
any ideas...
 
got it. cheers for help. for anyone else whoose looking -


<asp:datagrid AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="e-Mail">
<itemtemplate>
<a href='mailto:<%# Databinder.Eval(Container, "DataItem.e-Mail") %>'>
<%# Databinder.Eval(Container, "DataItem.e-Mail") %>
</a>
</itemtemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
 
Back
Top