Am trying to add to the navigation url in a hyperlink field.
I have 5 columns on my gridview, the last being
<asp:HyperLinkField DataNavigateUrlFields="vID"
DataNavigateUrlFormatString="Page2.aspx?field={0}" HeaderText="send"
Text="send"></asp:HyperLinkField>
and the code behind to add to it
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim hk As HyperLink = DirectCast(e.Row.Cells(4).Controls(0), HyperLink)
hk.NavigateUrl += "&TN=table1"
End Sub
I had it working yesterday, but must have accidentally deleted the code, and I cant find where am going wrong here, I get an error “Specified argument was out of the range of valid values.
Parameter name: index”
You must check the
RowType, otherwise you’re looking for theHyperLinkalso in the header.VB
C#