Connecting Tech Pros Worldwide Forums | Help | Site Map

datagrids and email addresses

kieran
Guest
 
Posts: n/a
#1: Nov 20 '05
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()

Ken Tucker [MVP]
Guest
 
Posts: n/a
#2: Nov 20 '05

re: datagrids and email addresses


Hi,
[color=blue]
> Dim col As DataColumn
> For Each col In ds.Tables(0).Columns
> lstItems.Items.Add(col.ColumnName)
> Next[/color]

Ken
----------------
"kieran" <kieran5405@hotmail.com> wrote in message
news:b39796b3.0404150658.72cb25b6@posting.google.c om...[color=blue]
> 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()[/color]


kieran
Guest
 
Posts: n/a
#3: Nov 20 '05

re: datagrids and email addresses


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...



"Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message news:<uFC57BzIEHA.3240@TK2MSFTNGP12.phx.gbl>...[color=blue]
> Hi,
>[color=green]
> > Dim col As DataColumn
> > For Each col In ds.Tables(0).Columns
> > lstItems.Items.Add(col.ColumnName)
> > Next[/color]
>
> Ken
> ----------------
> "kieran" <kieran5405@hotmail.com> wrote in message
> news:b39796b3.0404150658.72cb25b6@posting.google.c om...[color=green]
> > 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()[/color][/color]
kieran
Guest
 
Posts: n/a
#4: Nov 20 '05

re: datagrids and email addresses


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>






"Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message news:<uFC57BzIEHA.3240@TK2MSFTNGP12.phx.gbl>...[color=blue]
> Hi,
>[color=green]
> > Dim col As DataColumn
> > For Each col In ds.Tables(0).Columns
> > lstItems.Items.Add(col.ColumnName)
> > Next[/color]
>
> Ken
> ----------------
> "kieran" <kieran5405@hotmail.com> wrote in message
> news:b39796b3.0404150658.72cb25b6@posting.google.c om...[color=green]
> > 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()[/color][/color]
Closed Thread