您需要使用TemplateColumn。這將爲您提供可在ItemDataBound事件中使用的命名控件。
ASP
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink runat="server" ID="LinkColumn" NavigateUrl="" Text="View Details"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
VB
Private Sub ReportGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles ReportGrid.ItemDataBound
Const target = "/TeamsDetail.aspx?Account={0}&Broker={1) Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem
Dim ctrl = CType(e.Item.FindControl("LinkColumn"), HyperLink)
Dim row = CType(e.Item.DataItem, DataRowView)
If ctrl IsNot Nothing Then
Dim accountKey = CInt(row("PrincipalAccountKey"))
Dim brokerNumberKey = CInt(row("BrokerNumberKey"))
ctrl.NavigateUrl = String.Format(target, accountKey, brokerNumberKey)
End If
End Select
End Sub