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
and just use a different type of function
protected string FormatEmailHref(string email)
{
if(email.length>0)
{
return "<href mailto:'" + email + "'>" + email + "</a>";
}
return "n/a";
}
something like that.
Bookmark that sight for GRIDVIEW stuff.
"Bill" <bill_at...@yahoo.com> wrote in message
news:1170182606....@m58g2000cwm.googlegroups.com...
"Bill" <bill_at...@yahoo.com> wrote in message
news:1170182606....@m58g2000cwm.googlegroups.com...
-- 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("emailaddress{0}@hotmail.com", str);
table.Rows.Add(row);
}
return table;
}
</script>
-- end code --
hope this helps
Milosz