column called email in it. In designer, I am adding columns . I have added a
column "email" with the following parms:
HeaderText:Email
DataNavigateUrlField:email
DataNavigateUrlFormatString:mailto:{0}
DataTextField:email
ItemStyle | CssClass:gridlink
Nothing else has been set.
I expected the result to be a link that would open the default mail client.
Instead the text appears in the grid but the HTML tag generated is just
<a>my.mail@dotnet.itags.org.address.com</a>
ie no mailto has appeared. Is this the expected behaviour, am I doing
something wrong?Hi Sam,
Try fllowing code in RowDataBound event
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink link = (HyperLink)e.Row.Cells[col_index].Controls[0];
DataRowView drv = (DataRowView)e.Row.DataItem;
link.NavigateUrl = "mailto:" + drv[col_index].ToString()
}
HTH
Elton Wang
"sam" wrote:
> In asp.net 2.0 I have created a datagrid. The databind is to a table with a
> column called email in it. In designer, I am adding columns . I have added a
> column "email" with the following parms:
> HeaderText:Email
> DataNavigateUrlField:email
> DataNavigateUrlFormatString:mailto:{0}
> DataTextField:email
> ItemStyle | CssClass:gridlink
> Nothing else has been set.
> I expected the result to be a link that would open the default mail client.
> Instead the text appears in the grid but the HTML tag generated is just
> <a>my.mail@.address.com</a>
> ie no mailto has appeared. Is this the expected behaviour, am I doing
> something wrong?
Elton W
Thanks for the reply. What you suggest is similar to what I have done to
work around the problem. I am still none the wiser as to why the original
method does not work, and for future occassions would like to know, if only
to avaiod the extra coding!!
Thanks
Sam
"Elton W" wrote:
> Hi Sam,
>
> Try fllowing code in RowDataBound event
> if (e.Row.RowType == DataControlRowType.DataRow)
> {
> HyperLink link = (HyperLink)e.Row.Cells[col_index].Controls[0];
> DataRowView drv = (DataRowView)e.Row.DataItem;
> link.NavigateUrl = "mailto:" + drv[col_index].ToString()
> }
> HTH
> Elton Wang
>
> "sam" wrote:
> > In asp.net 2.0 I have created a datagrid. The databind is to a table with a
> > column called email in it. In designer, I am adding columns . I have added a
> > column "email" with the following parms:
> > HeaderText:Email
> > DataNavigateUrlField:email
> > DataNavigateUrlFormatString:mailto:{0}
> > DataTextField:email
> > ItemStyle | CssClass:gridlink
> > Nothing else has been set.
> > I expected the result to be a link that would open the default mail client.
> > Instead the text appears in the grid but the HTML tag generated is just
> > <a>my.mail@.address.com</a>
> > ie no mailto has appeared. Is this the expected behaviour, am I doing
> > something wrong?
In the end I went for setting email as the DataTextField and then putting
the entire tag in the DataTextFormatString - which worked fine: ie
DataTextFormatString =<a href=mailto:{0:G}?subject=mySubject - >{0:G}</a>
0 comments:
Post a Comment