在gridview databound事件中加入:
if (e.Row.RowType == DataControlRowType.DataRow)
{ foreach (TableCell tc in e.Row.Cells)
{ if (tc.Controls.Count > 0)
{ if (tc.Controls[0].GetType().FullName == "System.Web.UI.WebControls.HyperLink") { HyperLink hlink = (HyperLink)tc.Controls[0];
if (((HyperLink)tc.Controls[0]).Text.Contains("$"))
{
hlink.NavigateUrl = "upload/" + lblCatalog.Text + "/" + ((HyperLink)tc.Controls[0]).Text;
hlink.Text = ((HyperLink)tc.Controls[0]).Text.Split('$')[1];
hlink.Target = "_blank";
}
}
}
}
}