0

如果我要使用 html 设置列以使用电子邮件地址,我可以这样做:

<ItemTemplate>
    <a href="mailto:<%# Bind("email") %>"><%# Bind("email") %></a>
</ItemTemplate>

我如何动态地做到这一点?我试过做

e.Row.Cells[8].Text = "<a href='mailto:" + Eval(EMAIL_ADDRESS) + "'>" + Eval(EMAIL_ADDRESS) + "</a>";
4

2 回答 2

0
string emailAddy = e.Row.Cells[8].Text;
string strEM = "<a href='mailto:" + emailAddy + "'>" + emailAddy + "</a>";
e.Row.Cells[8].Text = strEM;
于 2013-10-29T18:09:04.143 回答
0

它应该是这样的:

System.Web.UI.HtmlControls.HtmlAnchor myAnchor = new System.Web.UI.HtmlControls.HtmlAnchor();
myAnchor.HRef = string.Format("mailto:{0}", myEmailAddress);
myAnchor.InnerText = myEmailAddress;
e.Row.Cells[8].Conntrols.Add(myAnchor);
于 2013-10-29T17:55:42.083 回答