You can just use the hyperlinkfield in the GridView control. You just need to set its parameters properly for it to be working the way you want it to. Here's my example.
DataTable dt = new DataTable();
dt.Columns.Add("linktext");
dt.Columns.Add("linktarget");
for (int i = 0; i < 5; i++)
{
dt.Rows.Add(new string[] {"google", "http://www.google.com"});
}
GridView1.DataSource = dt;
HyperLinkField hfield = ((HyperLinkField)GridView1.Columns[0]);
hfield.DataNavigateUrlFields = new string[]{dt.Columns[0].ColumnName,dt.Columns[1].ColumnName};
hfield.DataNavigateUrlFormatString = "{1}";
hfield.DataTextField = hfield.DataNavigateUrlFields[0];
GridView1.DataBind();
I basically create a gridview control and add a hyperlinkfield. Paste this code into the PageLoad event and see how it work.
Hope this helps.
Aldwin Enriquez
"Dont you ever give up!"
|