I have an ASP.NET Web Forms application. In my application I have a GridView that works smoothly. I have several text fields and the last one is a <asp:hyperlinkfield>
.
Now I would like to programmatically change the field by placing a simple link instead of the hyperlinkfield
if a specific condition is fulfilled. Therefore I catch the onRowDataBound
event:
Sub myGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles myGridView.RowDataBound
If (condition) Then
Dim link = New HyperLink()
link.Text = "login"
link.NavigateUrl = "login.aspx"
e.Row.Cells(3).Controls.Add(link)
End If
End If
End Sub
where n is the cell where the hyperlinkfield
is placed. With this code it just adds to the hyperlinkfield
the new link
. How can I replace it?
PS: The code is in VB6 but I am a C# programmer, answers with both languages are accepted