Sure, example that should show you how to accomplish this task:
-- begin code --
<asp:GridView runat="server" ID="gridView" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate>No.</HeaderTemplate>
<ItemTemplate>
<%# Container.DataItemIndex.ToString() %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Name" DataField="Name"/>
<asp:BoundField HeaderText="Email" DataField="Email"
DataFormatString="<a href='mailto:{0}'>{0}</a>"/>
</Columns>
</asp:GridView>
<script runat="server">
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gridView.DataSource = GetExampleData(10);
gridView.DataBind();
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
private DataTable GetExampleData(int rowCount)
{
DataTable table = new DataTable();
DataRow row = null;
table.Columns.Add("Id", typeof(Guid));
table.Columns.Add("Name", typeof(String));
table.Columns.Add("Email", typeof(String));
string str;
for (int i = 0; i < rowCount; i++)
{
str = i.ToString();
row = table.NewRow();
row[0] = Guid.NewGuid();
row[1] = "Name" + str;
row[2] = String.Format("em*************@hotmail.com", str);
table.Rows.Add(row);
}
return table;
}
</script>
-- end code --
hope this helps
Milosz
"Bill" wrote:
Say I want to pull a bunch of records from a contacts database into a
gridview and one of the fields contains an email address. Now suppose
I want to make that email address clickable by putting it in a string
(strEmail) and wrapping it in a hyperlink like this ASP Classic
example...
"<a href='mailto:" & strEmail & "'>" & strEmail & "</a>"
How do I pull that off in a gridview? Step by step or tutorial link
would be great if available.
I am using VS 2005, ASP.Net 2.0 with C# code behind.
Thanks for your help in advance,
Bill