如果我使用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>";
答案 0 :(得分: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);
答案 1 :(得分:0)
string emailAddy = e.Row.Cells[8].Text;
string strEM = "<a href='mailto:" + emailAddy + "'>" + emailAddy + "</a>";
e.Row.Cells[8].Text = strEM;