currently I am trying to use this databind method to assign the NavigateURL property of a radgrid gridhyperlinkcolumn for each row. Unfortunately, for each row, the link is set as the system key of the row previous. So if these are my rows:
- SystemName|SystemKey
- Sys1|1
- Sys2|2
- Sys3|3
Sys1 will have no link, Sys2 will have a link to ~/System.aspx?Key=1 and Sys3 will have a link to ~/System.aspx?Key=2 I've gathered that it's likely setting the NavigateURL property after the row's url has already been set and therefore only affects the next row? So how do I set this property properly?
Current Code:
Protected Sub rg_Systems_ItemDataBound(ByVal s As Object, ByVal e As GridItemEventArgs) Handles rg_Systems.ItemDataBound
If TypeOf e.Item Is GridDataItem Then
Dim col As GridHyperLinkColumn = rg_Systems.MasterTableView.GetColumn("SystemName")
Dim item As GridDataItem = e.Item
Dim newUrl As String = "~/System.aspx?Key=" & item.GetDataKeyValue("SystemKey").ToString()
col.NavigateUrl = newUrl
End If
End Sub
You can directly do this without code-behind: