Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
Dim oRow As DataRowView
If TypeOf e.Item Is Telerik.Web.UI.GridDataItem Then
'cast e.item
Dim item As GridDataItem = e.Item
'this gives us access to the data side of things
oRow = CType(e.Item.DataItem, DataRowView)
Dim strStatus As String = oRow("status")
Dim intID As Int32 = oRow("ID")
'get a reference to a TEMPLATED control
Dim hypSubject As HyperLink = CType(e.Item.FindControl("hypSubject"), HyperLink)
hypSubject.Text = oRow("subject")
'use business logic on the control
If strStatus = "Article" Then
hypSubject.NavigateUrl = "~/Article.aspx?ArticleID=" & intID
Else
hypSubject.NavigateUrl = "~/Thread.aspx?threadid=" & intID
End If
'get an indirect reference to a GridBoundColumn
Dim oItem As GridDataItem = DirectCast(e.Item, GridDataItem)
oItem("itemdesc").ForeColor = System.Drawing.Color.Red
oItem("itemdesc").Font.Bold = True
'get a direct reference to a GridButtonColumn
Dim btnSopnumber As LinkButton = CType(item("sopnumbe").Controls(0), LinkButton)
btnSopnumber.Enabled = False
End If
'used to reference the group headers
If TypeOf e.Item Is GridGroupHeaderItem Then
oRow = CType(e.Item.DataItem, DataRowView)
Dim bLocked As Boolean = oRow("Locked")
If bLocked Then
Dim btnReceive As RadButton = CType(e.Item.FindControl("btnReceive"), RadButton)
btnReceive.Visible = False
End If
End If
End Sub