Asp.net 如何使用条件以编程方式更改超链接文本?

Asp.net 如何使用条件以编程方式更改超链接文本?,asp.net,vb.net,Asp.net,Vb.net,我的aspx页面中有此模板字段: 如果cell9不等于Catcher,但我得到的对象引用错误未设置为对象实例,则我必须将超链接文本更改为N/A。 如果不满足上述条件,如何更改超链接文本?要获取超链接,需要在当前行中找到控件,而不是在整个gridview中,如下所示 Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound

我的aspx页面中有此模板字段:

如果cell9不等于Catcher,但我得到的对象引用错误未设置为对象实例,则我必须将超链接文本更改为N/A。
如果不满足上述条件,如何更改超链接文本?

要获取超链接,需要在当前行中找到控件,而不是在整个gridview中,如下所示

Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
   If e.Row.RowType = DataControlRowType.DataRow Then
      Dim fgr As HyperLink = DirectCast(e.Row.FindControl("fgr"), HyperLink)
      If e.Row.Cells(2).Text = "Catcher" Then
        e.Row.Cells(9).Enabled = True
      Else                       
        fgr.Text = "N/A"
      End If
   End If
 End Sub
Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
   If e.Row.RowType = DataControlRowType.DataRow Then
      Dim fgr As HyperLink = DirectCast(GridView1.FindControl("fgr"), HyperLink)
      If e.Row.Cells(2).Text = "Catcher" Then
        e.Row.Cells(9).Enabled = True
      Else                       
        fgr.Text = "N/A"
      End If
   End If
 End Sub
Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
   If e.Row.RowType = DataControlRowType.DataRow Then
      Dim fgr As HyperLink = DirectCast(e.Row.FindControl("fgr"), HyperLink)
      If e.Row.Cells(2).Text = "Catcher" Then
        e.Row.Cells(9).Enabled = True
      Else                       
        fgr.Text = "N/A"
      End If
   End If
 End Sub